Chapter 30.  TCP/IP Communications

Communication across a TCP/IP network, such as the Internet, may be performed by way of REALbasic’s built-in Socket control. Using a Socket, your application can function as a client or as a server. The two cases work slightly differently, so they are considered separately in this chapter.[149]

If you’ve never coded for TCP/IP communications before, don’t panic. It’s just a matter of sending text messages back and forth, like telegrams. The main trick is knowing what message to send when, and how to respond to the messages that you receive. That knowledge is what makes up the protocol for the particular sort of communication you’re doing. A protocol is simply the list of rules for talking back and forth—a little language, if you will. If you are writing both the client and the server for private use, you can invent your own protocol. If you want to write an application that acts as a client or server for some public standard, you will need to follow the protocol for that standard; for example, if you want your application to speak to or act as a web server, you have to follow the protocol called HTTP.[150]

There are two ways to instantiate a Socket:

  • Drag the Socket icon from the Tools Window into a Window Editor; or create a Socket subclass, and drag the subclass from the Project Window into the Window Editor. The window will automatically instantiate the Socket when it is itself instantiated. The icon that appears in the Window ...

Get REALBasic: TDG, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.