if you are interested to contribute your LAB PROGRAM Please send mail to jkumaron@gmail.com

Socket Listen Source code in C Programming Network lab

To verify whether the socket is in listener mode and to find
the binded port number.It will be used in the chat application programming.
Source code in C programming Algorithm CS1305 Network Lab Socket Listen
STEP 1: Start the program.
STEP 2: Declare the variables fd, b, l.
STEP 3: Declare the family, type, protocol, queue length and
port number for the socket.
STEP 4: The socket is created and the field descriptor value is displayed.
STEP 5: The socket is binded at the specified port.
STEP 6: The listen function is used.
STEP 7: If the returned value is positive then the server is said
to be in listener mode.
STEP 8: Stop the program.

PROGRAM Free source code in C CS1305 Network Lab Socket Listen
#define PORT 450
#define quelen 5
int main( )
int fd,b,l;
struct sockaddr_in myaddr;
printf(“Socket Creation Error”);
printf(“Socket Created”);
printf(“Socket Field Description Value is%d\n”,fd);
b=bind(fd,(struct sockaddr*) &myaddr,Sizeof
(struct sockaddr));
printf(“Socket Binding Error”);
printf(“socket is binded at port %d\n”,PORT);
printf(“Socket listen Error”);
printf(“Server is in listener mode”);
return 0;
Output CS1305 Network Lab Socket Listen
Socket Created.
Socket Field Descriptor Value is 3
socket is binded at port 450
Server is in listener mode
RESULT Thus the program for performing socket listen has
been created and verified.

Related post