Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Listening and responding to connection requests

> After you enable a server socket for listening using the `ENABLE-CONNECTIONS( )` method, Progress listens on the specified port for client connections. When a socket client sends a connection request to this port, Progress automatically accepts the connection.

> After accepting the connection, Progress posts a `CONNECT` event on the server socket and calls the `CONNECT` event procedure that you have specified using the `SET-CONNECT-PROCEDURE( )` method. The `CONNECT` event procedure executes, returning a handle to a socket object created by Progress and passed as a parameter to the event procedure context. This socket object, then, is the communications endpoint for the connection on the server.

> | To listen for connections on a server socket using the `CONNECT` event procedure:

> 1. Define an internal procedure that takes one `INPUT` parameter of type `HANDLE` to serve as an event procedure. You can define this procedure in any procedure context that is active while listening for connections.

> 2. Specify the procedure you defined in Step 1 as a `CONNECT` event procedure by invoking the `SET-CONNECT-PROCEDURE( )` method on the server socket handle that you have enabled for listening.

> 3. Include blocking I/O statements (such as `WAIT-FOR`) or `PROCESS EVENTS` statements in your code to handle events. When any `CONNECT` event is received in the context of one of these statements, the event procedure specified in Step 2 executes.

> Once you have the handle to a connected socket object, you can read and write data on the socket, and otherwise manage the socket for the connection. For more information, see the "Read, writing, and managing sockets on clients and servers" section.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095