mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
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:
parent
f918e8913a
commit
cb13c6459c
2 changed files with 46 additions and 0 deletions
25
Testing/tcpport-client.m
Normal file
25
Testing/tcpport-client.m
Normal 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
21
Testing/tcpport-server.m
Normal 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);
|
||||
}
|
Loading…
Reference in a new issue