• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 40. Network Programming > Writing Your Own Client and Server

Writing Your Own Client and Server

Applets are restricted from connecting to just any Web server. They can only connect back to the server from which they were downloaded. If you want to give an applet access to the rest of the Internet, you'll need to place a server on the same machine that hosts the applet. You can use a commercial server such as a File Transfer Protocol (FTP) server, or you can write your own special-purpose server.

When you write a server, you write a program that opens a socket (typically on a well-known port number) and wait for some client to connect. The client calls in from some unused port number (called an ephemeral port). As soon as the client and the server connect, it's common for the server to propose that the conversation continue on a different port. This design frees up the well-known port number to handle a new connection. Table 40.1 shows some common, well-known port numbers. These services are offered both on TCP ports and on UDP ports. The RFC column refers to the Internet Request for Comments document, where you'll find the specification for the service.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint