Category : sockets

Using ctypes in python can convert C struct to python object. But if C++ struct like this (maybe using socket to transfer C++ struct to python): struct Struct { int a; vector<int> b; } I’m wondering how to convert C++ struct bytes with variable vector to python object. Thanks Source: Windows Que..

Read more

I’m writing a socket c++ lib for TCP. I’m compiling with GCC for x86_64-w64-mingw32.7.3.0 on windows 10. When I try to build a socket I fail. listenSocket = socket(AF_INET, SOCK_STREAM, 0); if (listenSocket < 0) { std::cout << "ERROR: OPEN SOCKET" << listenSocket << std::endl; close(listenSocket); return; } Getting the error. ERROR: OPEN SOCKET-1 Seem ..

Read more

src.cpp #include <iostream> #include <cstring> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> int main(){ struct addrinfo hints, *servinfo; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; getaddrinfo(NULL, "1560", &hints, &servinfo); freeaddrinfo(&hints); } I used gdb to find out where the error occurs and it occurs at the memset but when I ..

Read more