winsock2

Make c++ not wait for user input

半腔热情 提交于 2019-12-22 17:54:32
问题 So, i am trying to make a c++ WinSock2 chatter, just for learning. It is a console application and i want to take user input (for sending to the counterpart), but i still want to be able to recive. (so you can write a message while still being able to recive one)... When using cin >> input; the program "pauses" until the user has enterd something, that way it is "turn based" (one user writes something and sends it, then the other user writes something and sends it). Is there a way to make the

WINSOCK - Setting a timeout for a connection attempt on a non existing IP?

微笑、不失礼 提交于 2019-12-20 11:43:28
问题 I am developing a RTSP Source filter in C++, and I am using WINSOCK 2.0 - blocking socket. When I create a blocking socket, I set its SO_RCVTIMEO to 3 secs like so: int ReceiveTimeout = 3000; int e = setsockopt(Socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&ReceiveTimeout, sizeof(int)); My filter tries to connect to IP_ADDRESS:554 (554 is RTSP server port). If there is a server listening on that IP on the port 554, all goes well, but: If my filter creates a socket to an existing IP address , but on

WINSOCK - Setting a timeout for a connection attempt on a non existing IP?

只谈情不闲聊 提交于 2019-12-20 11:43:15
问题 I am developing a RTSP Source filter in C++, and I am using WINSOCK 2.0 - blocking socket. When I create a blocking socket, I set its SO_RCVTIMEO to 3 secs like so: int ReceiveTimeout = 3000; int e = setsockopt(Socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&ReceiveTimeout, sizeof(int)); My filter tries to connect to IP_ADDRESS:554 (554 is RTSP server port). If there is a server listening on that IP on the port 554, all goes well, but: If my filter creates a socket to an existing IP address , but on

Why does the following code make my computer beep?

拥有回忆 提交于 2019-12-20 05:19:27
问题 I'm having a really hard time understanding why is this piece of code making my computer beep. I've isolated this section of code to be the one producing the occasional beep, but I don't see what's the problem with it. const int BUFFER_LENGTH = 8192; char buffer [BUFFER_LENGTH + 1]; int recvResult; do { recvResult = recv(webSocket, buffer, BUFFER_LENGTH, 0); buffer[recvResult] = '\0'; printf("%s", buffer); if (recvResult > 0) { sendResult = send(clientSocket, buffer, recvResult, 0); } }while

Is it possible to tell if WSAStartup has been called in a process?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 11:08:43
问题 I've started writing an ActiveX control that makes use of sockets. Applications that use this control may or may not also use sockets. Is it possible for my control to tell whether WSAStartup has been called? If not, call it. A little test reveals that calling WSAStartup multiple times is tollerated. But what happens if a different winsock version is requested? will this break other parts of the application? 回答1: Yes it is possible. And here is how it's done. bool WinsockInitialized() {

recv() returns always 0

六月ゝ 毕业季﹏ 提交于 2019-12-14 02:14:16
问题 I've a problem with recv() function that I can't explain: it always returns 0. I've a client/server application in which the server simply has to receive a string from the client through the internet (different pc). There are no connectivity problems, and I also tried to send a string from server to client: it worked. I search in the blog and what I found, recv() socket function returning data with length as 0, non-blocking recv returns 0 when disconnected, Recv returning zero incorrectly,

Multiple Socket client connecting to a server

a 夏天 提交于 2019-12-13 05:41:50
问题 I am designing an simulator application where the application launches multiple socket connection(around 1000 connections) to a server. I don't want to launch as many as threads to handle those connections, since the system cant handle that much clients. Using Select doesnt make sense, since i need to loop through 1000 connections which may be slow. Please suggest me how to handle this scenario. 回答1: You want to be using asynchronous I/O with an I/O Completion Port (IOCP). It's too much to

OpenSSL in a VisualC++ DLL

和自甴很熟 提交于 2019-12-13 02:24:59
问题 i'm trying to write a C++ DLL which uses openSSL to secure a connection to a server. I'm genuinly puzzled by the fact that this code #include "stdafx.h" #include <string.h> #include <iostream> //SSL stuff #include <openssl/ssl.h> #include <openssl/err.h> #include <openssl/pem.h> #include <openssl/x509.h> #include <openssl/x509_vfy.h> #include <openssl/ossl_typ.h> #include <openssl/applink.c> //Winsock stuf #pragma comment(lib, "ws2_32.lib") {... Create a method in which we set up the SSL

Why does MinGW-w64 require winsock2 to be manually included?

孤街醉人 提交于 2019-12-12 16:12:59
问题 Some code and associated warnings/errors: #include <windows.h> #include <iphlpapi.h> int main() { } F:/Prog/mingw-w64/x86_64-4.9.2-win32-seh-rt_v3-rev1/mingw64/x86_64-w64-mingw32/include/ws2ipdef.h:71:3: error: ' ADDRESS_FAMILY ' does not name a type ADDRESS_FAMILY si_family; #include <windows.h> #include <winsock2.h> #include <iphlpapi.h> int main() { } // this compiles successfully, only gives warning F:/Prog/mingw-w64/x86_64-4.9.2-win32-seh-rt_v3-rev1/mingw64/x86_64-w64-mingw32/include

FireBreath FB::PluginWindowWin include problem

痴心易碎 提交于 2019-12-12 05:42:52
问题 I tried to follow the steps in the answer of Directx control in browser plugin but when I added the solution mentioned in http://colonelpanic.net/2010/11/firebreath-tips-drawing-on-windows/ FireBreath Tips: Drawing on Windows "1.Make your plugin object windows specific change the type of the event source specified in EVENTTYPE_CASE to FB::PluginWindowWin (as well as the type in the handlers) and you will have your object cast in the way you need it." I got 119 errors, all are in winsock2.h