winsock

Which socket, the clientSocket = accept() or the listen(socket), do you setsockopt SO_KEEPALIVE on?

Which socket, the clientSocket = accept() or the listen(socket), do you setsockopt SO_KEEPALIVE on to get the connection to clients not to drop? ...

Why doesn't this C++ code work?

int Socket::Connect(const std::string& host, int port) { if(this->_connected) throw "Socket is already connected"; // Get the IP from the string hostent* ip = gethostbyname(host.c_str()); /*if(server == NULL) throw strerror(WSAGetLastError());*/ // Information for WinSock. sockaddr_in addr; ...

Implement a good performing "to-send" queue with TCP

In order not to flood the remote endpoint my server app will have to implement a "to-send" queue of packets I wish to send. I use Windows Winsock, I/O Completion Ports. So, I know that when my code calls "socket->send(.....)" my custom "send()" function will check to see if a data is already "on the wire" (towards that socket). If a da...

C++ winsock error

Hello , i have a simple server that accepts clients. The client connect to the server. The first thing the server will do the following: grab the client socket create a thread for client call ::recv(); the problem here is that recv returnes -1 WSAGetLastError returnes WSAENOTSOCK: (Socket operation on nonsocket.) Microsoft: "An oper...

Seeking info on how to use the VB6 Winsock, flow of events, etc.

I'm using the MS Winsock control in VB6 and I want to understand things like "when does the Server Close the connection (triggering the Winsock_Close() event), and a related question: How do you know when all the data from a a Post has been returned? More info: I should have mentioned: I've already read the MSDN description, etc....

How do you know when all the data has been received by the Winsock control that has issued a POST or GET to an Web Server?

I'm using the VB6 Winsock control. When I do a POST to a server I get back the response as multiple Data arrival events. How do you know when all the data has arrived? (I'm guessing it's when the Winsock_Close event fires) ...

Winsock: Accept on global socket, start new thread and copy there, free previous global

Hello there guys It is pure winsock server question. Just to clear that I already know how threads work. I have global sockets called Global and Main_Socket. long __stdcall newthreadfunction(); //prototype of new thread function SOCKET Global; // To be shared and copied by thread SOCKET Main_Socket; //main listening socket WSADATA w...

C++ windows32 winsock UDP routing?

In C++ using Windows32 using windows socket library using UDP is there a way to give a client routing information to another client to establish a connection between clients without having to route through the server Clarification: server - waits for computers and gives routing info - a detached server client - sends a ack request and ...

ConnectEx with IOCP problem

I've made a simple dummy server/dummy client program using IOCP for some testing/profiling purpose. (And I also wanted to note that I'm new to asynchronous network programming) It looks like the server works well with original client, but when the dummy client tries to connect to the server with ConnectEx function, IOCP Worker thread st...

Calculating socket upload speed

Hi, I'm wondering if anyone knows how to calculate the upload speed of a Berkeley socket in C++. My send call isn't blocking and takes 0.001 seconds to send 5 megabytes of data, but takes a while to recv the response (so I know it's uploading). This is a TCP socket to a HTTP server and I need to asynchronously check how many bytes of ...

MinGW WinSock struct definition missing

I have the source for a cross-platform library. It compiles fine under MSVC but I'd like to compile it under MinGW. The MinGW winsock2.h does not contain a definition for the defintion for struct ip_mreq, which is found in Windows' SDK WinSock.h file. What is an elegant way to go about fixing this (among other discrepancies yet to be d...

Acessing browser socket using Winsock SPI(LSP)

Hi, how can i access to the socket, that is used by web browser. Or how can i get data transfered between web browser and web server. I need to connect to that socket and modify the data, the web browser sends and recieves. What concrete functions should i use? I studiend the msdn documentation about this, but didnt noticed how do i get...

what is the protocol parameter in winsock's socket function for?

The winsock function socket expects as third parameter the protocol what usually is IPROTO_TCP for socket type SOCK_STREAM and IPROTO_UDP for socket type SOCK_DGRAM. When I pass a 0 value as the protocol parameter, TCP and UDP work as expected. SOCKET s = socket(AF_INET, SOCK_DGRAM, 0) // s is a valid socket What is the IPROT...

How to wait until your TCP message has been ACKed

Background: We have a client/server application that uses a persistent connection to the server. Benchmarks show that it is many times faster to use an already open connection rather than spend significant time (2.5 seconds) setting up a new connection (crypto). Unfortunately, the old connection may be stale. Is there a way to wait f...

Winsock and other network possibilities in Windows

Hi, on windows, is there any other option when programming network communication then using Winsock? There are many socket libraries for c++, are they all just winsock based? ...

Detecting user from winsock data?

Hi. For example i create socket using winsock under account named Admin. Is there any possibility to detect which user created that socket? I would like to write in my program: This socket was created by "Admin". i am using c++ ...

How to set Keepalive on Windows Server 2008

Hello, I have win32 application in which winsock is used for TCP/IP communication. I am setting keepalive value with WSAIoctl function and it is working normally with windows XP. But on Win. Server 2008 WSAIoctl fails, and WSAGetLastError returns 10022(invalid arguments) which does not make any sense. My code which sets keepalive is fo...

How to correctly handle WSAECONNABORTED in server code?

When a server receives a WSAECONNABORTED from a device (coming in from a send()), should a connection be re-established and data re-sent or should the server bail out and drop the connection? Thanks. ...

passing native winsock socket to java socket

Hello. I need to pass a native winsock socket created by C++ application to a library in my application that uses java.net.Socket to connect to a server. This winsock appication already take care of connecting the socket. how can I explicitly set the socket descriptor of java.net.Socket? ...

How to tell if end of remote file is reached using Winsock (VB6)?

I am developing a program on top of a basecode taking care of low level socket programming. The problem seems to be that the only way it knows (apparently) when to stop close the connection is when the amount of bytes received exceed that given in the "Content-length" field. But since that field is not set for many sites I don't know how...