It’s code from client part (using )
struct sockaddr_in stSockAddr;
int Res;
int SocketFD;
SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (-1 == SocketFD)
{
perror("cannot create socket");
exit(EXIT_FAILURE);
}
memset(&stSockAddr, 0, sizeof(stSockAddr));
stSockAddr.sin_family = AF_INET;
stSockAddr.sin_port = htons(8182);
Res = inet_pton(AF_INET, "127.0.0.1", &stSockAddr.sin_addr);
And I get responce from server using
char buffer[4096] = "";
n = read(aSocketFD, buffer, 4096);
My questin is:
Can I get responce like std::basic_filebuf? Or can I get responce to FILE *?
Socket is a file handler, so I can do it, but how?
For C code, you can use a descriptor like FILE* calling fdopen(): associates a stream with a file descriptor (POSIX.1 standard).