winsock

How do I determine the remote endpoint a UDP packet originates from?

The socket is created and bound, then the program receives data with recv(). The question is: How do I now determine from which host + port the packet originates so that I can send data back? Note: C and Winsock is used. ...

sockaddr_in6 not declared?

I'm trying to port an ipv4 server/client to ipv6, but the compiler says SOCKADDR_IN6 is not declared in the scope. SOCKADDR_IN is declared but not SOCKADDR_IN6. <Winsock2.h> is included. Any one have any ideas why it would be undeclared? ...

Winsock - stop accepting new connections yet keep comm with existing connections.

I have a Winsock based server application which uses Windows Winsock I/O Completion Ports. As such, each connection accepted is associated with the listening socket to start receiving notifications (read, write, close etc'). The listening socket has a backlog of 100 pending connections. All is good. At some point I want to stop accepti...

Winsock structure to store path for IPC.

In unix the sockaddr_un structure exists to hold a path. Is there some windows equivalent. I've been looking all over the place and haven't found anything. ...

Multiple sockets receiving same packet

I have a C++ program written with Winsock that has multiple blocking sockets operating in multiple threads. They are all waiting at recvfrom(), and when I send a packet to one of them, they all get the packet. Here is how they are declared: _sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); if (_sock == INVALID_SOCKET) { _error = WSAG...

Winsock alternative (no, not WinPCAP)

Are there any viable alternatives to Winsock for C++? The reason I need of is because Winsock's raw sockets are not behaving properly (no, this is not fixable, don't waste your time asking) and WinPCAP can only monitor network traffic, not actually receive packets. I need something that can receive complete packets including any IP, UDP,...

Using Winsock "send" function in Java (or similar)

Hi all, I have a feeling my problem is a bit strange, but here goes... I have a C++ program (from another organization) that interacts with a camera connected to hardware via Ethernet using sockets. On the surface, the initial function that sends a message to the socket is this: char* cmd = "#TRGON\x0d"; m_pClient->Socket_Write( (BYTE*...

Threading in Windows using C++

Hi, In C++ how can you use threads to not block my receive functionality in case of Sockets? // Receive until the peer closes the connection do { iResult = recv(lhSocket, recvbuf, recvbuflen, 0); if ( iResult > 0 ) printf("Bytes received: %d\n", iResult); else if ( iResult == 0 ) printf("Connection closed\n...

Bitmap transfer using Winsock, GetDIBits and SetDiBits

Hello. I started working on something similar to a remote control application in c++. I wish to transfer a particular window's screenshot to another PC and display it in a window. Both GetDIBits and SetDIBits functions succeed, the connection is established, the data is sent, yet the image does not appear on the other side, just blacknes...

WinINet trouble downloading file to client?

I'm curious why I'm having trouble with this function. I'm downloading a PNG file on the web to a destination path. For example, downloading the Google image to the C: drive: netDownloadData("http://www.google.com/intl/en_ALL/images/srpr/logo1w.png", "c:\file.png"); The file size is correct after downloading. Nothing returning false. W...

c++ winsock code does not work in its original solution/project in visual studio 2010

Hey... I am not 100% sure if I shall become insane... As mentioned in many many other posts, I am writing this Connection class which stats up winsock, creates some sockets, binds them and let´s you send and receive some data... I made this within my Server-project... But , everytime i wanted to test the connection part of the server ...

assignin sockaddr to another changes the addr?!?

While trying the following the address in the second sockaddr changes: /*Stuff*/ sockaddr add1, add2; recvfrom(/*socket*/, /*buffer*/, /*count*/, /*flag*/, &add1, /*fromlen*/); add2 = add1; //The sa_data - part changes O_o... /*Stuff*/ Anyone knows why?... EDIT: 1.I changed the sockaddr to sockaddr_storage which definetly has enou...

How to implement application protocal

Hi all We want to implement a server/client application for internal use. Does anyone have know how to implement an application protocol based on the socket? Best Regards, ...

copying sockaddr_storage to another sockaddr_storage changes address

Hey... As in a recent question (nobody did react on the last changes) I have a problem with assigning a sockaddr structure filled by recvfrom. As I have been advised , I did change my sockaddr to sockaddr_storage and casted it in the last moment to be sure of having enough space for the address... But the problem of sockaddr_storage ...

winsock: recvfrom does not receive in release build(VS 2010)

Hey... I wanted to build my client program in release mode and everything seemed to work fine. The client was able to send data, which have been received by the server. But the client never receives the answer sent by the server. The server is working correctly The data size is only up to 200 bytes sending works... I am using Visual S...

How to Send a structure using sendto()

I have created structure : struct buffer { string ProjectName ; string ProjectID ; } buffer buf; buf.ProjectID = "212"; buf.ProjectName = "MyProj"; Now to send this structure using sendto method , I am typecasting the strucure and sending it back as below: char *sendbuf = (char*)&buf; sentbytes = sendto(sock,sendbuf,strlen(s...

problem with UDP broadcast?

If I broadcast using a UDP socket using sendto() and call recvfrom() immediately. I am receiving the broadcast message that I have sent from the same PC a little while ago? Can this loop back kind of thing be avoided some how?? any explanation why am I experiencing such loop back kind of thing? I mean how long does broadcast message stay...

Is it possible to do requests through a proxy with csoap under windows ?

I'm trying to do csoap request through a authenticated http proxy, and this doesn't seems supported. Tell me if I'm wrong. I'm not exactly sure to understand the problem. It seems that the issue goes down to which winsock doesn't automatically use the Internet Settings configured proxy. I suppose that this is the correct behavior of wi...

What is Network Adapter Index? What is Network Interface Index?

The MSDN is super confusing on this one. What is their relation? Who has an IP address (or several) - an adapter or an interface? In many places MSDN talks about them as if they're synonymous, but sometimes they make a distinction. ...

How do I properly shut down an IOCP server?

I can find tonnes of article's about starting up an IOCP server, but none about properly shutting it down =/ What is the proper way to shut the server down when you are done? more specifically, I already use PostQueuedCompletionStatus() to tell the worker threads to quit, but don't I also need to cancel all the pending IO, and close all...