libs-base/Examples/port-server.m
Andrew McCallum b591762987 (main): Beginnings of changes for new port scheme.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1469 72102866-910b-0410-8b05-ffd578937521
1996-04-18 01:54:33 +00:00

28 lines
535 B
Objective-C

#include <stdio.h>
#include <gnustep/base/SocketPort.h>
#define MSG "Hello back to you, from a server SocketPort"
int main()
{
id packet;
id p = [TcpPort newLocalWithNumber:3];
id rp;
int len;
char *buf;
for (;;)
{
packet = [p receivePacketWithTimeout: -1];
len = [p streamBufferLength];
buf = [p streamBuffer];
if (len >= 0 && len < 32)
buf[l] = '\0';
printf("(length %d): %s\n", len, buf);
[p sendPacket:MSG length:strlen(MSG)
toPort:rp
timeout:15000];
}
exit(0);
}