winsock

Winsock2: How to allow ONLY one client connection at a time by using listen's backlog in VC++

Hi Everyone, I want to allow only one connection at a time from my TCP server. Can you please tell, how to use listen without backlog length of zero. I m using the code(given below), but when i launch 2 client one by one, both gets connected. I m using VC++ with winsock2. listen(m_socket,-1); passing zero as backlog is also not work...

Checking if a Socket has closed in C++

I have a small application that redirects the stdout/in of an another app (usually command prompt or bash for windows). The problem is that if the connection is interrupted the my process has no idea and it never closes because of this line: WaitForSingleObject(childProcess.hThread, INFINITE) I was thinking of having a loop with somet...

Performance debugging network throughput of minimal Winsock2 app

I have a very simple Winsock2 TCP client - full listing below - which simply blasts a bunch of bytes. However, it's running very slowly over the network; the data just trickles by. Here's what I've tried and found (both Windows PCs are on the same LAN): Running this app from one machine to the other is slow - it takes ~50s to send 8MB...

How to support both IPv4 and IPv6 connections

Hello, I'm currently working on a UDP socket application and I need to build in support so that IPV4 and IPV6 connections can send packets to a server. I was hoping that someone could help me out and point me in the right direction; the majority of the documentation that I found was not complete. It'd also be helpful if you could poin...

ASP.net (MVC) and Winsock

I'm working with asp.net MVC. Now I don't know how to send data form a server (using asp.net ) to another server using (win32 console command line). Plz help me. P/S: Is there any security hole in this method. ...

What's the delay for in TCP/UDP?

HELP PLEASE! I have an application that needs as close to real-time processing as possible and I keep running into this unusual delay issue with both TCP and UDP. The delay occurs like clockwork and it is always the same length of time (mostly 15 to 16 ms). It occurs when transmitting to any machine (eve local) and on any network (we hav...

Using .NET to get results from an API

I wanted to use the Rapidshare API in my .NET app, but I am confused on how you send the request and bring back the result. Do you use Winsock or another method? URLs are like this: http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=288725357&filenames=my_upload.txt Thanks. ...

Use Winsock insde DShow Filter

Hi, I am trying to develop a DirectShow filter with internet access. When I try to use Winsock, 1) In TCP, I wait connections but cannot access to server (try with Telnet) and 2) In UDP in data wait step (recvfrom(...)) program breaks. Is it not possible? Or do I have to change library settings for the filter? ...

C Network Programming - Winsock

Hey, I have been learning C over the last two weeks, managed to get my head around pointers, arrays and structures. I am looking to do a bit of socket programming on windows and was wondering if anyone has any websites with tutorials and examples or suggest books that teach network programming with winsock? I have tried looking for so...

Select() problems in C (windows 7)

I am trying to create a server which uses select() to handle multiple clients, as opposed to multi-threading which I have already accomplished. However select() just doesn't seem to do anything? I have all the necessary system calls e.g. socket() returning to an int called listener. bind() then listen(), all with suitable error checking,...

Statically linking Winsock?

I'm using Winsock 1.1 in my project. I include wsock32.lib in "Additional Dependencies". I'm looking at the DLL project using depends.exe and notice that the DLL depends on wsock32.dll. How can I statically link it so that it doesn't depend on wsock32.dll? ...

close() vs. shutdown() with recv()

I have the following code: Client side: n=recv(sock,buf,1200,NULL); Server side: shutdown(sockk,SD_BOTH); The problem is, the client side recv is returning 0, meaning graceful shutdown. I need it to return -1 (I can't change the client side, I need to adapt my code to it.) What can i do to cause it returning -1? ...

WinSock Client C

I have a client using select() to check if there is anything to be received, else it times out and the user is able to send(). Which works well enough. However, the program locks up waiting for user input, so it cant recv() again until the user has sent something. I am not having much luck with using threads either, as I cannot seem to ...

Asynchronous address resolution in winsock?

Looking into asynchronous address resolution in winsock it seems that the only two options are either to use the blocking gethostbyname on a seperate thread, or use WSAAsyncGetHostByName. The latter is designed for some reason to work with window messages, instead of overlapped operations and completion ports/routines. Is there any vers...

How to get internal IP, external IP and default gateway for UPnP

I'm wondering how I'd go about getting the: Internal IP address; External IP address; and Default gateway in Windows (WinSock) and Unix systems. Thanks in advance, ...

How to read exact number of bytes from a stream (tcp) socket?

In winsock, both the sync recv and the async WSARecv complete as soon as there is data available in a stream socket, regardless of the size specified (which is only the upper limit). This means that in order to read a fixed number of bytes from the stream, there should be applied some custom buffering. And unless each read is buffered se...

getaddrinfo() returning only ::1 as IPV6 address,

I'm using getaddrinfo() to return all assigned IP addresses (both IPv4 and IPv6) for my local machine. I see that on XP, getaddrinfo() only returns ::1 ( I installed the IPV6 stack on 2 XP machine and configured the IPV6 address and pinged the both peers. they are working fine. I check the Ipconfig its all working fine. ) ...

Qt (Creator) with WinSocks (ws2_32)

I want to use an older code-fragment in my Qt-project, which is using WinSocks. I created my program with Qt Creator and I don't know, how I can link to the ws2_32-Library. I already added LIBS += -lws2_32 to my .pro, but nothing happened. So how can I link to this library? edit: Where can I find the ws2_32.lib to include it? Do I have...

Rejecting a TCP connection before it's being accepted?

There are 3 different accept versions in winsock. Aside from the basic accept which is there for standard compliance, there's also AcceptEx which seems the most advanced version (due to it's overlapped io capabilities), and WSAAccept. The latter supports a condition callback, which as far as I understand, allows the rejection of connecti...

IO Completion ports: How does WSARecv() work?

Hi,I want to write a server using a pool of worker threads and an IO completion port. The server should processes and forwards messages between multiple clients. The 'per client' data is in a class ClientContext. Data between instances of this class are exchanged using the worker threads. I think this is a typical scenario. However, I h...