Category : sockets

I have this client socket connection code. #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include "Connection.h" #include "WinSockComp.h" #include <WinSock2.h> #include <Windows.h> #include <WS2tcpip.h> #include <iphlpapi.h> #include <stdio.h> #include <string> const char PORT[16]="11111"; const char SDS_ADDRESS[16] = "0.0.0.0"; WSADATA wsaData; SOCKET Connection::get() { WinSockComp winSockComp = WinSockComp(); // Instantier og initializer et SOCKET objekt. SOCKET socketConnection = ..

Read more

my qt code like this … connect(socket, SIGNAL(readyRead()), this, SLOT(readBluetoothDataEvent()) ); … void Widget::readBluetoothDataEvent() { QByteArray line = socket->readAll(); // std::string comStr=line.toStdString(); char *aa; aa=line.data(); std::cout<<aa<<std::endl; when i send data "4321n" from ESP32 via bluetooth, i got result like this: 4 3 2 1 So why readyread() emit every one charactor? Source: Windows Que..

Read more

I try to open o socket on windows between my 2 computers with windows10 professional and compile it to a C file with codeblock 20.03 IDE.Here is my code #include <sys/types.h> #include <winsock2.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <Ws2tcpip.h> #define BUF_SIZE 500 int main(int argc, char *argv[]) { int sfd; char ..

Read more

I am replacing old code to linux. I was using: server_host = getipnodebyname(host.c_str(), AF_INET, 0, &err_num); and server_host = getipnodebyaddr(addr, sizeof(INET_ADDRSTRLEN), AF_INET, &err_num); that it has to be replaced by the new getaddrinfo(). At moment I added: struct addrinfo *p_addr = (struct addrinfo *) NULL; struct addrinfo hints={0}; //Initialize the addrinfo hints char addr[INET_ADDRSTRLEN]={0}; int ..

Read more