SIZED_IO

Section: Misc. Reference Manual Pages (3NBS)
Updated: 11 January 1988
Index Return to Main Contents
 

NAME

initport, sized_read, sized_write - send datagrams using TCP  

SYNOPSIS

#include <sys/socket.h>
#include <netinet/in.h>
#include <inet.h>

int s = initport(PORT_NUMBER(XXX),SERVER,SOCK_STREAM);

int client = select_server_stream(s,&fds);
int s;
int fds;

int cc = sized_read(fd,buffer,maxsize)
int cc = sized_write(fd,buffer,size)
int fd;
char *buffer;
int maxsize;  

DESCRIPTION

This package implements packet or stream IO between a server process and a number of client processes, using the TCP/IP (stream) facilities. It is particularly useful to send packets larger than that allowed by UDP. UDP packets are also not reliable - these are.

A client uses the call:

s is the server's data socket and is used as a file descriptor in further communication. The port may be specified by name (PORT_NAME("foo")), if it is registered.

Similarly, the server uses the following call:

s is the server's connection socket. To receive data or connections, the server calls select_server_stream().

This returns a file descriptor corresponding to a client, when a client has sent a message to the server. It handles initial connections as well as client deaths. s is the server's connection socket that was returned by initport(). fds is an int used by select...() for storing a bit string corresponding to client sockets. Initialize it to 0, and don't mess with it after that.

To use the file descriptors in a stream-oriented manner, use read() and write(). To use the file descriptors in a packet-oriented manner, use sized_read() and sized_write(). The sized...() calls read and write one packet at a time, while packet boundaries are ignored in read() and write().

The arguments for sized_read() and sized_write() are very similar to read() and write(). The only difference is that in sized_read(), maxsize is the maximum size of an acceptable packet.  

AUTHOR

Don Libes - National Bureau of Standards


 

Index

NAME
SYNOPSIS
DESCRIPTION
AUTHOR

This document was created by man2html, using the manual pages.
Time: 06:23:48 GMT, December 12, 2024