mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Test the reply port mechanism; look for messages coming back from the
server. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1072 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
591e85df32
commit
5959e1d40b
1 changed files with 29 additions and 9 deletions
|
@ -1,25 +1,45 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <objects/TcpPort.h>
|
#include <objects/TcpPort.h>
|
||||||
|
|
||||||
int main ()
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
id port;
|
id out_port;
|
||||||
|
id in_port;
|
||||||
id packet;
|
id packet;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test"
|
if (argc > 1)
|
||||||
onHost: @"localhost"];
|
out_port = [TcpOutPort newForSendingToRegisteredName:
|
||||||
|
[NSString stringWithCString: argv[1]]
|
||||||
|
onHost: @"localhost"];
|
||||||
|
else
|
||||||
|
out_port = [TcpOutPort newForSendingToRegisteredName: @"tcpport-test"
|
||||||
|
onHost: @"localhost"];
|
||||||
|
|
||||||
|
in_port = [TcpInPort newForReceiving];
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
packet = [[TcpPacket alloc] initForSendingWithCapacity: 100
|
packet = [[TcpPacket alloc] initForSendingWithCapacity: 100
|
||||||
replyPort: nil];
|
replyPort: in_port];
|
||||||
[packet writeFormat: @"Here is message number %d\n", i];
|
[packet writeFormat: @"Here is message number %d", i];
|
||||||
[port sendPacket: packet withTimeout: 20 * 1000];
|
[out_port sendPacket: packet withTimeout: 20 * 1000];
|
||||||
[packet release];
|
[packet release];
|
||||||
|
|
||||||
|
packet = [in_port receivePacketWithTimeout: 1000];
|
||||||
|
if (packet)
|
||||||
|
{
|
||||||
|
fprintf (stdout, "received >");
|
||||||
|
fwrite ([packet streamBuffer] + [packet streamBufferPrefix],
|
||||||
|
[packet streamEofPosition], 1, stdout);
|
||||||
|
fprintf (stdout, "<\n");
|
||||||
|
[packet release];
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[port close];
|
[out_port close];
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue