mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
3a43130da6
248 changed files with 40027 additions and 0 deletions
39
Examples/port-client.m
Normal file
39
Examples/port-client.m
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <stdio.h>
|
||||
#include <objects/SocketPort.h>
|
||||
|
||||
#define MSG "Hello from a client SocketPort."
|
||||
#define BUFFER_SIZE 80
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char b[BUFFER_SIZE];
|
||||
int len;
|
||||
id remotePort;
|
||||
id localPort = [SocketPort newLocal];
|
||||
id rp;
|
||||
|
||||
if (argc > 1)
|
||||
remotePort = [SocketPort newRemoteWithNumber:3 onHost:argv[1]];
|
||||
else
|
||||
remotePort = [SocketPort newRemoteWithNumber:3 onHost:""];
|
||||
|
||||
strcpy(b, MSG);
|
||||
[localPort sendPacket:b length:strlen(b)
|
||||
toPort:remotePort
|
||||
timeout: 15000];
|
||||
len = [localPort receivePacket:b length:BUFFER_SIZE
|
||||
fromPort:&rp
|
||||
timeout:15000];
|
||||
|
||||
if (len == -1)
|
||||
{
|
||||
fprintf(stderr, "receive from SocketPort timed out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
b[len] = '\0';
|
||||
printf("(length %d): %s\n", len, b);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue