Skip to content
/ net Public

Simple API for TCP/SSL, client/server applications for Unix

Notifications You must be signed in to change notification settings

funlibs/net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Net

Simple wrapper (one header file) around TCP and SSL for unix/linux.

Example:

HTTP Get request on a webserver 443 port:

#include "net.h"
#include <stdio.h>

#define MAX_REPLY 1000


int
main(int argc, char** argv) {

    int count;
    char* request = "GET / HTTP/1.0\r\nHost: www.google.fr\r\n\r\n";
    char reply[MAX_REPLY + 1];
    NetSocket socket;

    socket = netDial("www.google.fr", 443, NET_TCP | NET_SSL | NET_SYNC);
    if (socket.fd < 0)
        return 1;

    if (netWrite(socket, request, strlen(request)) >= 0)
        while ((count = netRead(socket, reply, MAX_REPLY)) > 0)
            printf("%s", reply);

    netClose(socket);

    return 0;
}
gcc exemple.c -L/usr/lib -lssl -lcrypto -o exemple

About

Simple API for TCP/SSL, client/server applications for Unix

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published