Socket - Introduction on Socket Socket is an endpoint for...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction on Socket Socket is an endpoint for communication between two machines. The most popular application architecture is the client-server architecture. The server will create a server socket and wait for a socket to connect. The client will create a socket and connect to the server. Once the connection is established, messages can be sent between the client and server. This basic procedure is illustrated in C and Java. Details of the functions used can be found on the internet. C Socket Header files: #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> Server Side int sockfd, newsockfd, clilen; struct sockaddr_in serv_addr, cli_addr; //create a socket sockfd = socket(AF_INET, SOCK_STREAM, 0 ); if (sockfd < 0 ) error( "ERROR opening socket" ); //bind to a port //initialize server address to 0 bzero(( char *) sizeof (serv_addr)); //set address info serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; //set port number, normally a number larger than 1024
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/04/2011 for the course CIS 4643 taught by Professor Staff during the Spring '07 term at University of Central Florida.

Page1 / 3

Socket - Introduction on Socket Socket is an endpoint for...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online