This is port-server.m in view mode; [Download] [Up]
#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); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.