 |
| Using named pipes for interprocess communication |
User rating: 0/10 (0 votes) | |
|
|
 |
 |
| Before you begin: |
 |
This code sample contains definitions of two classes, NamedPipeServer and NamedPipeClient, encapsulating named pipes API functionality.
The Pipes, as well as mailslots, can be used for transferring data between processes running on same computer or on different computers.
See also:
Peer-to-peer LAN messenger built with Mailslot API functions
Using mailslots to send messages on the network
Using WM_COPYDATA for interprocess communication
|
 |
 |
| |
| |
Members area. Log in to view this example. |
|
| |
|
|
|
|
|
 |
User rating: 0/10 (0 votes) | |
| 5512 bytes Created: 2007-01-21 20:24:52 Modified: 2010-05-19 22:37:13 Visits in 7 days: 54 |
|
 |
 |
| Listed functions: |
 |
|
 |
 |
| My comment: |
 |
Use the following code to run pipe server.
LOCAL oServer As NamedPipeServer
oServer = CREATEOBJECT("NamedPipeServer", "\\.\pipe\tpipe")
WITH oServer
IF NOT .Listen()
? .errorcode, .errormsg
ENDIF
ENDWITH
Starting the pipe server switches current VFP session to a waiting state. Thus it stays frozen until receiving a request from a pipe client.
This is a sample client code.
LOCAL oClient As NamedPipeClient
oClient = CREATEOBJECT("NamedPipeClient", "\\.\pipe\tpipe")
WITH oClient
IF NOT .SendMessage(SYS(0))
? .errorcode, .errormsg
ENDIF
ENDWITH
Normally a pipe server application, written in programming language other than FoxPro, would create a separate threads for listening and for processing incoming requests.
If the pipe client code runs on a different computer than the pipe server, in the pipe client code substitute the dot "." in the pipe name with the computer name or ip address of the pipe server.
Pipe server accepts connections on TCP port 139 (NetBIOS).
 |
 |
 |
| Word Index links for this example: |
 |
|
|
 |
 |
| Translate this page: |
 |
|