Part 1: http://programmingundersecurity.blogspot.in/2014/01/understanding-socket-programming-part-1.html
Header Files Used
#include <netinet/in.h> - Constants and strucutres needed for Internet Domain Address
#include <sys/socket.h> -Structures needed for sockets
#include <sys/types.h> - Data types used in System calls
Client Side Procedures
- Create a socket with socket() system call
- Connect the socket to the address of the server using the connect() system call.
- Send and receive data. There are a number of ways to do this, but the simplest way is to use the read() and write() system calls.
- Create a socket with the socket() system call.
- Bind the socket to an address using the bind() system call. For a server socket on the Internet, an address consists of a port number on the host machine.
- Listen for connections with the listen() system call.
- Accept a connection with the accept() system call. This call typically blocks the connection until a client connects with the server.
- Send and receive data using the read() and write() system calls.
Structures Used
Understand about various structures from herehttp://www.tutorialspoint.com/unix_sockets/socket_structures.htm
Server Code : http://www.cs.rpi.edu/~moorthy/Courses/os98/Pgms/server.c
Client Code: http://www.cs.rpi.edu/~moorthy/Courses/os98/Pgms/client.c
Other Tutorial: https://www.cs.cf.ac.uk/Dave/C/node28.html
No comments:
Post a Comment