New file.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1031 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-03-01 16:26:49 +00:00
parent f918e8913a
commit cb13c6459c
2 changed files with 46 additions and 0 deletions

25
Testing/tcpport-client.m Normal file
View file

@ -0,0 +1,25 @@
#include <stdio.h>
#include <objects/TcpPort.h>
int main ()
{
id port;
id packet;
int i;
port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test"
onHost: @"localhost"];
for (i = 0; i < 5; i++)
{
packet = [[TcpPacket alloc] initForSendingWithCapacity: 100
replyPort: nil];
[packet writeFormat: @"Here is message number %d\n", i];
[port sendPacket: packet withTimeout: 20 * 1000];
[packet release];
}
[port close];
exit (0);
}

21
Testing/tcpport-server.m Normal file
View file

@ -0,0 +1,21 @@
#include <stdio.h>
#include <objects/TcpPort.h>
int main ()
{
id port;
id packet;
port = [TcpInPort newForReceivingFromRegisteredName: @"tcpport-test"];
while ((packet = [port receivePacketWithTimeout: 20 * 1000]))
{
fprintf (stdout, "received >");
fwrite ([packet streamBuffer], [packet streamEofPosition], 1, stdout);
fprintf (stdout, "<\n");
[packet release];
}
fprintf (stdout, "Timed out. Exiting.\n");
exit (0);
}