https://ameblo.jp/kissam59/entry-12559533556.html
で紹介したサンプルプログラムを変更してみました。
低水準入出力関数:Write(), Read()をソケットAPIで置き換えます。
// For send/recv functions/soket API
#include <sys/socket.h>
を追記すると
send()とrecv()が使用できます。なのですが、network.hの中で#include されていました。
// write(client, buf, strlen(buf));
// https://www.freebsd.org/cgi/man.cgi?query=send(2)
send(client, buf, strlen(buf), 0);
snip
// len = read(client, buf, sizeof(buf)-1);
// https://www.freebsd.org/cgi/man.cgi?query=recv(2)
len = recv(client, buf, sizeof(buf)-1, 0);
な感じです。
【参考記事】