mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +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
e02b57fc4e
commit
c5f461d3a3
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…
Add table
Add a link
Reference in a new issue