1994-11-04 16:29:24 +00:00
|
|
|
#include <stdio.h>
|
1996-04-17 18:40:03 +00:00
|
|
|
#include <gnustep/base/SocketPort.h>
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
#define MSG "Hello back to you, from a server SocketPort"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
1996-04-18 01:54:33 +00:00
|
|
|
id packet;
|
|
|
|
id p = [TcpPort newLocalWithNumber:3];
|
1994-11-04 16:29:24 +00:00
|
|
|
id rp;
|
1996-04-18 01:54:33 +00:00
|
|
|
int len;
|
|
|
|
char *buf;
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
1996-04-18 01:54:33 +00:00
|
|
|
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);
|
1994-11-04 16:29:24 +00:00
|
|
|
|
|
|
|
[p sendPacket:MSG length:strlen(MSG)
|
|
|
|
toPort:rp
|
|
|
|
timeout:15000];
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|