Raw Sockets
INTRODUCTION TO SOCKETS:
Sockets
A socket is a communication mechanism. A socket is normally identified by a small integer, which may be called the socket descriptor. The socket mechanism was first introduced in the 4.2 BSD UNIX systems in 1983 in conjunction with the TCP/IP protocols that first appeared in the 4.1 BSD UNIX systems in late 1981.Formally a socket is defined by a group of four numbers, these are
• The remote host identification number or address
• The remote host port number
• The local host identification number or address
• The local host port number
Users of Internet applications are normally aware of all except the local port number, this is allocated when connection is established and is almost entirely arbitrary unlike the well-known port numbers associated with popular applications. To the application programmer the sockets mechanism is accessed via a number of functions. These are.
socket() Create a socket
bind() associate a socket with a network address
connect() connect a socket to a remote network address
listen() wait for incoming connection attempts
accept() accept incoming connection attempts
In addition the functions setsockopt(), getsockopt(), fcntl() and ioctl() may be used to manipulate the properties of a socket, the function select() may be used to identify sockets with particular communication statuses. The function close() may be used to close a socket liaison.
Data can be written to a socket using any of the functions write(), writev(), send(), sendto() and sendmsg(). Data can be read from a socket using any of the functions read(), readv(), recv(), recvfrom() and recvmsg()
These notes have been written in the context of SUN's Solaris 2 operating system, in particular version 2.5. Other operating systems and environments will provide similar facilities and functions but reference to the documentation is advised. In particular many of the functions described here may well be system calls, i.e. direct entries to the operating system.
for more info visit.
http://www.enjineer.com/forum
No comments:
Post a Comment