Class TServerSocket (unit Unit3) |
This sample creates a socket using TAsyncSocket in TObject mode as opposed to TComponent. The procedures are the same basically for both with the exception of using override statements instead of clicking and obtaining the 'OnEvent' code in the designer. You will still probably need to write a new class for any project of considerable complexity even if you use the TComponent version, so the TObject version is demonstrated here. Notice the EVENT_LISTEN in the Sockets unit. It is a define that will tell the code what events to listen for on a basic listening socket. If you want the events changed, change the define and recompile. Pay close attention to these defines because no matter what socket objects you inherit and how you override their functions, the initial events will NOT be triggered unless they are defined in the EVENT area. The only exceptions to this are the OnListen and OnError. They will be called always because of the way they are implemented. If you wish them to do nothing, either override their respective procedures or remove the message box defines. (They only pop a message box up in their default states). TServerSocket - the socket that will listen for new connections.
Constructors |
Functions |
Properties |
Events |
Variables |
Constructors |
Functions |
This is to prevent a brutal circular reference in Pascal. if you put this in the upper uses clause you will get an error. In my opinion, one of the BIG reasons to use Borland's C++ Builder. Note that these overrides do not need to call the base class because the base class procedures do nothing except put a message box on the screen. Read over TWMSocket to see the various data that can be extracted from it.
Now, assuming no errors, the tempSocket is initialized to the incoming connection. It is ready to be used. We will now ship it off to the TListView to have it added to the display.
Properties |
Events |
Variables |