answersLogoWhite

0


Best Answer

Elementary system calls

A socket created with the socket call is identified only by its address family and type. It has no name. Without a name, processes cannot reference it and no communication can take place. Communication processes are bound by an association. In the UNIX domain, an association is composed of local and foreign path names (pathnames created by a foreign process). In the internet domain, an association consists of a local address and port number, and a foreign address and port number.

The bind(SSC) system call allows a process to specify the local half of this association by binding an address to the local end of a socket. The call takes the form:

bind(s, name, namelen);

Arguments to bind include the socket, a pointer to the address (name), and the length of the address (namelen). Thus bound, a process is able to rendezvous with an unrelated process. The operation is asymmetric, with one process taking the role of server and the other of client.

Servers

Server sockets listen passively for incoming connection requests

rather than actively initiating them. To create a server socket, call listen(SSC) after the socket is bound.

listen(s,backlog);

The listen call identifies the socket that receives the connections and marks it as accepting connections. The maximum queue length (backlog) that listen can specify is five.

A call to listen does not complete the connection; it only indicates a willingness on the part of the server process to listen for incoming connection requests. Applications must call accept(SSC) to establish an actual connection. The accept call takes takes the form:

accept(s, addr, addrlen)

The addr and addrlen arguments return the address of the connected client process, and accept automatically creates a new socket descriptor. Assuming the server is concurrent, the process immediately forks and the child process handles the connection while the parent continues to listen for more connection requests.

Clients

Client sockets actively initiate calls, rather than listening passively for incoming connection requests. Active sockets use the connect(SSC) function to establish connections. To create a socket to rendezvous with a server, use the socket call as before. With streams sockets, it is not necessary to bind an address to the client (see table below). This is because with a connection-oriented protocol the server's address must be known, but the client's address is unimportant because no other process will try to access it. With connectionless sockets, however, each datagram must contain the destination address of the client and an address bound to it with the bind system call.

A client process issues the connect call in an attempt to establish a connection with a listening server process. A connection is a mechanism that avoids the need to transmit the identity of the sending socket each time data is sent. The connect call provides for the exchange of the identities of each endpoint just once, prior to the transmission of data. Successful completion of connect results in a connection between two sockets.

connect(s, name, namelen)

connect does not return until a connection is established. s is the socket descriptor of the client process. name and namelen are pointers to the address family and size of the other socket.

Establishing a connection

Client Server

socket() socket()

bind()

listen()

connect() accept()

Data transfer

Once a pair of sockets is connected, data can flow from one to the other. Data can be sent and received with any of several system calls. The read(S) and write(C) functions may be used to do this, just as they are for normal files.

read(fildes, buf, nbyte)

write(fildes, buf, nbyte)

fildes refers to the socket descriptor returned by the socket call in the client, and by accept in the server. The write system call attempts to write nbyte bytes from the buffer pointed to by buf to the socket associated with fildes.

The send(SSC) and recv(SSC) calls are almost identical to read and write, except that they provide a flags argument.

send(s, msg, len, flags)

recv(s, msg, len, flags)

The flags argument may be specified as non-zero if the MSG_PEEK constant is required.

The MSG_PEEK flag lets the caller look at the data without discarding it as read. When specified in a recv call, any data present is returned to the user but treated as though still unread. The next read or recv call applied to the socket will return the data previously previewed.

The close(S) system call is used to discard the end of a socket connection when it is no longer needed. If one end of a socket is closed and the other tries to write to it, the write will return an error. s is the socket descriptor being closed in:

close(s)

If the socket is a stream socket, the system will continue to attempt to transfer data. The shutdown(SSC) call causes all or part of a full-duplex connection to be terminated:

shutdown(s, how)

If argument how is 0, further receives are disabled. When how is 1, further sends are disallowed, while 2 disallows additional sends and receives.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: List and describe all elementary socket systems calls and data transfer calls?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can I use a metric socket on a standard socket wrench?

No, you cannot use a metrc socket on a standard socket wrench. These are two different systems of measurement and are not interchangeable.


What is a line-out socket?

A line-out socket is a socket found on items that play audio content to allow them to be connected to sound systems, etc.


What does 20 mm socket transfer to in inches?

It is approx 0.79 inches.


What three sockets are currently used for Intel processors in mothers boards for desktop systems?

Socket 1366 Socket 1156 Socket 1155 Socket LGA 2011 are in use presently


What does 39.5 mm socket transfer to in inches?

39.5 millimeters is 1.56 inches.


What size socket to use on silverado transfer case drain bolt?

18mm


What does a 33mm socket transfer to in inches?

33mm converts to 1.3 (1.29921) inches.


What does 25 mm socket transfer to in inches?

25mm socket equals i(one) inchAnswer25mm socket equals i(one) inch Direct Conversion Formula25 mm*1 in25.4 mm=0.9842519685 in


What size socket do you use on the jeep transfer case fill and drain bolts?

30mm


What operating systems support Secure socket tunneling protocol?

Most modern operating systems (Windows, Linux, Unix, mainframes) support SSH and SSL.


What size Allen wrench fits 97 jeep wrangler transfer case fill plug?

30 mm socket


What is the difference between ports and bus?

Based on the definitions at the associated links, a bus is an electronic connection which allows the transfer of information, whereas a port is a socket in the side of a computer which allows a matching plug to connect to that computer.