Download presentation
Presentation is loading. Please wait.
1
Jan-11-06 Ecs152b Behrooz Khorashadi
Socket Server Side Jan-11-06 Ecs152b Behrooz Khorashadi
2
Clean up Struct sockaddr Struct sockaddr_in
Remember all this structure does is specify an address and port. Family whatever 2bytes 4 bytes 8bytes Port Int address Unused
3
Client Side Create Socket Connect (blocks, three way handshake)
Send/Receive Close connection
4
Server Create socket Bind socket to port (for a client this is done automatically in connect) Listen for incoming connection Accept connection Send/Receive Close connection
5
Bind bind(int socket, struct sockaddr *server_address, unsinged int addresslength) Remember sockaddr is actually the sockaddr_in struct Return 0 on success and -1 on fail
6
Listen int listen(int socket, int queue_limit)
Home many people can try and connect at a given time. Same as bind 0 on success -1 on fail
7
Accept int accept(int socket, struct sockaddr *clientaddr, unsigned int *addresslength) Creates a socket for you and doesn’t do anything to your listening socket. Puts relevant information into clientaddr and addresslength Success returns the socket descriptor of new socket, on fail return -1
8
Close Yeah sorry forgot
9
Questions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.