Networking
Simple bsd socket based data transfer library.
XCode project includes targets for iOS and OSX, but the source code can be complied for any POSIX compliant system. It is possible to transfer data to and from the iOS version of the lib to and from any other complied version.
Code is based on the BSD sockets example from Wikipedia: https://en.wikipedia.org/wiki/Berkeley_sockets
To compile the sample program:
- cd into the "Networking" directory.
- gcc -c JLNet.c
- gcc -c main.c
- gcc JLNet.c main.c -o JLNetDemo
- ./JLNetDemo
Make sure you have one instance waiting to recieve before launching another to send data.
The syntax is rather simple. The source directory includes main.c with a sample data transfer program.
#include <stdio.h>
#include "JLNet.h"
int main(){
printf("Send or recieve (s/r): ");
unsigned char sendrecieve = getc(stdin);
if (sendrecieve == 's')
senddata("What are you doing?", "127.0.0.1", 2343);
else
printf("I got a message: %s\n", recvdata(2343));
return 0;
}