mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Initial revision
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
commit
0098375b73
248 changed files with 40027 additions and 0 deletions
28
Examples/port-server.m
Normal file
28
Examples/port-server.m
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <objects/SocketPort.h>
|
||||
|
||||
#define MSG "Hello back to you, from a server SocketPort"
|
||||
#define BUFFER_SIZE 80
|
||||
|
||||
int main()
|
||||
{
|
||||
char b[BUFFER_SIZE];
|
||||
int l;
|
||||
id p = [SocketPort newLocalWithNumber:3];
|
||||
id rp;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
l = [p receivePacket:b length:BUFFER_SIZE
|
||||
fromPort:&rp
|
||||
timeout:-1];
|
||||
if (l >= 0 && l < 32)
|
||||
b[l] = '\0';
|
||||
printf("(length %d): %s\n", l, b);
|
||||
|
||||
[p sendPacket:MSG length:strlen(MSG)
|
||||
toPort:rp
|
||||
timeout:15000];
|
||||
}
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue