previous | start | next

The Socket Abstraction

The socket was introduced in BSD Unix (in the early 1980s) as a way of extending the Unix file I/O model to handle network communications.
 
Sockets (and the TCP software to which they form the interface) are implemented in all modern operating systems as system calls; that is, they form part of the operating system kernel. In modern object-oriented languages such as Java (and others), a socket class is implemented "on top of" these basic system-level services.
 
TCP sockets in Java are different for server and client processes. For a client process, a socket is created as follows:
Socket myclientsocket = new Socket("ironbark", 79);
This creates a new Socket object which is associated with a TCP (ie, reliable) connection to port 79 on ironbark. The newly created socket can be used as both an input and output stream, see next slide.
 
Lecture 9: Socket Programming Interface Copyright © 2005 P.Scott, La Trobe University Bendigo.


previous | start | next