winsock

WSAEventSelect model

南笙酒味 提交于 2020-01-13 07:09:10
问题 Hey I'm using the WSAEventSelect for event notifications of sockets. So far everything is cool and working like a charm, but there is one problem. The client is a .NET application and the server is written in Winsock C++. In the .NET application I'm using System.Net.Sockets.Socket class for TCP/IP. When I call the Socket.Shutdown() and Socket.Close() method, I receive the FD_CLOSE event in the server, which I'm pretty sure is fine. Okay the problem occurs when I check the iErrorCode of

winsock not supporting read/write

我怕爱的太早我们不能终老 提交于 2020-01-10 04:18:47
问题 With a small test program (compiled with mingw on Linux), I noticed that one cannot use the read and write calls on the socket fd as obtained using Winsock2's implementation of the socket call. The write call returns <0 and sets errno=EBADF. Think of programs run from xinetd, minus their assumption that their stdin/stdout always is a socket. (Some programs do call getpeername for example, which will fail if it is not a socket, subsequently they may exit prematurely.) So how are {file

Connect JavaScript WebSocket to C winsock

大兔子大兔子 提交于 2020-01-07 02:35:11
问题 I managed to connect my JavaScript client to C++ server (I'm using winsock), and the server receives a HTTP header, but I can't send or receive anything else after that. The server sends the message (send returns the number of bytes sent), but nothing arrives on the client. Client: JavaScript function WebSocketTest() { if ("WebSocket" in window) { var ws = new WebSocket("ws://192.168.43.205:80"); ws.onopen = function() { ws.send("Message to send");//this doesn't work }; ws.onmessage =

v8 release mode linker error with winsock

為{幸葍}努か 提交于 2020-01-06 20:12:36
问题 This subject became a side subject after I accepted an answer for my last question, so I will put it here as a separate topic for neatness, and I believe this will make it more useful for others. I am working on MS visual studio 2005. I am building a project using v8 in release mode, and am receiving a linker error that is related to winsock even though the winsock libraries are already in my additional dependencies. My additional dependencies list is the same for both release and debug mode.

How to control the connect timeout with the Winsock API?

情到浓时终转凉″ 提交于 2020-01-06 08:03:44
问题 I'm writing a program using the Winsock API because a friend wanted a simple program to check and see if a Minecraft server was running or not. It works fine if it is running, however if it is not running, the program freezes until, I'm assuming, the connection times out. Another issue is, if I have something like this (pseudo-code): void connectButtonClicked() { setLabel1Text("Connecting"); attemptConnection(); setLabel1Text("Done Connecting!"); } it seems to skip right to attemptConnection(

Does Winsock support IPv6 extension headers?

六眼飞鱼酱① 提交于 2020-01-06 06:53:12
问题 Is it possible to look at (and modify) IPv6 extension headers with Winsock using C/ C++? What API's allow us to do that? 回答1: IPv6 headers are not received using Raw Sockets on Winsock. As this MSDN page says For IPv6 (address family of AF_INET6), an application receives everything after the last IPv6 header in each received datagram regardless of the IPV6_HDRINCL socket option. The application does not receive any IPv6 headers using a raw socket. In other words, it's not possible to receive

Sending BYTE* over socket

☆樱花仙子☆ 提交于 2020-01-05 09:30:09
问题 I'm trying to send a BYTE* over a socket, but the send function only allows me to send a char* buffer. Is this possible? How would I go about casting it back on the other side? 回答1: Use reinterpret_cast to cast from BYTE* to char* . A BYTE is an unsigned char typedef, so you shouldn't have any issues. char* foo = reinterpret_cast<char*>(bar); Where bar is your BYTE* . 来源: https://stackoverflow.com/questions/27513776/sending-byte-over-socket

Receiving UDP packets using winsock

淺唱寂寞╮ 提交于 2020-01-05 08:42:37
问题 I'm getting UDP packets from the port continuously. Following is the log from wireshark. How to receive those packets continuously using winsock programming. I tried but I can't able to receive. After recvfrom() call it is not writing into a buffer.Give me idea, how to receive each packet in a buffer and write each packet into to a text file. Please help me. Thanks in advance... Source IP is 192.168.13.25 & port no is 2780 (Source is a Hardware which will send UDP packets continuously) Dest

HTTP POST mutli part “BAD REQUEST”

蓝咒 提交于 2020-01-05 06:51:07
问题 I'm trying to upload a file using POST here's my request : POST /upload.php HTTP/1.1 Host: localhost Content-Type: multipart/form-data; boundary=---------------------------552335022525 Content-Length: 192 -----------------------------552335022525 Content-Disposition: form-data; name="userfile"; filename="12.txt" Content-Type: text/plain blabla -----------------------------552335022525-- Using HTTP live headers firefox plugin everything works but when putting it a char *buffer and send it with

How do I send wide characters using winsock's send() function?

谁说我不能喝 提交于 2020-01-04 14:04:33
问题 It says here that the send function expects const char*. How do I send wide characters? I tried the following: void MyClass::socksend(const wchar_t* wbuffer) { int i; char *buffer = (char *)malloc( MB_CUR_MAX ); wctomb_s(&i,buffer, MB_CUR_MAX, (wchar_t)wbuffer); int buflen = strlen(buffer) + 2; char sendbuf[DEFAULT_BUFLEN]; strcpy_s(sendbuf,buflen,buffer); sendbuf[buflen - 1] = '\n'; int senderror = send(this->m_socket, sendbuf, buflen, 0); // error handling, etc goes here... } This doesn't