winsockets

Overlapped WSARecv() Callback Not Being Called in MFC App

那年仲夏 提交于 2020-02-05 06:35:46
问题 I have a COM component, implemented in C++ with ATL, that uses overlapped socket I/O. Right after the connection is made to the server, it starts an overlapped read on the socket, with code like this: // Pass pointer to this instance as hEvent parameter, for use by callback m_recvOverlapped.hEvent = reinterpret_cast<HANDLE>(this); int rc = ::WSARecv(m_s, &wsabuf, 1, &m_recvNumberOfBytes, &m_recvFlags, &m_recvOverlapped, RecvCallback); if (rc == SOCKET_ERROR) { // If error is WSA_IO_PENDING,

Hunt down java.net.SocketException: No buffer space available

大憨熊 提交于 2019-12-19 05:52:48
问题 Hi I have very ugly problem with: java.net.SocketException: No buffer space available (maximum connections reached?) It is client-server app. Client is Windows XP SP2 32b, with two net cards core duo. Java 1.6. u7. Application have couple server socket open for local communication and couple of client socket for rmi to jboss server. After couple of hours/days! i am unable to open any new client socket to do communication to server. Server sockets still works. Windows netstat shows something

C++ Winsock P2P

泪湿孤枕 提交于 2019-12-17 04:24:08
问题 Scenario Does anyone have any good examples of peer-to-peer (p2p) networking in C++ using Winsock? It's a requirement I have for a client who specifically needs to use this technology (god knows why). I need to determine whether this is feasible. Any help would be greatly appreciated. EDIT And I would like to avoid using libraries so that I can understand the underlying source code and further my knoweldge. 回答1: Since I don't know what information you are looking for, I'll try to describe how

Object reference not set to an instance of an object button press event [duplicate]

China☆狼群 提交于 2019-12-14 03:28:30
问题 This question already has answers here : What is a NullReferenceException, and how do I fix it? (29 answers) Closed 6 years ago . I'm getting an error message and I don't know how to fix it. This is the original code I have: private void SendMessage(Command cmd, EndPoint sendToEP) { try { //Create the message to send. Data msgToSend = new Data(); //msgToSend.strName = txtName.Text; //Name of the user. msgToSend.cmdCommand = cmd; //Message to send. msgToSend.vocoder = vocoder; //Vocoder to be

How to simulate a client server application I wrote in c++ using windows sockets?

时光怂恿深爱的人放手 提交于 2019-12-12 01:01:45
问题 I was asked recently to write a client server application so I did this using c++ and windows sockets and I tried it on two pcs on a LAN and it worked pretty well.My professor wants to see this working for real but I thought there could be a way to simulate that application and show that it works without having to connect two Pcs and so on....how can I do that? 回答1: You dont have to simulate anything, just run it on one machine and use 127.0.0.1 (thats an address of localhost loopback) as an

How to get domain name from Given IP in MFC (VC++)?

一笑奈何 提交于 2019-12-11 23:06:39
问题 How to get domain name from Given IP in MFC (VC++) ? The code i am using is as below: #include "stdafx.h" #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> // link with ws2_32.lib #pragma comment(lib, "Ws2_32.lib") int _tmain(int argc, char **argv) { //----------------------------------------- // Declare and initialize variables WSADATA wsaData = {0}; int iResult = 0; DWORD dwRetval; struct sockaddr_in saGNI; char hostname[NI_MAXHOST]; char servInfo[NI_MAXSERV]; u_short port =

How to get the ip address under Windows

故事扮演 提交于 2019-12-11 16:55:53
问题 all i already had a "socketfd", and i was wondering how to use it to retrieve the local ip address. under linux, i can do something like this(not exactly correct): struct ifreq ifr; ifr.ifr_addr.sa_family = AF_INET; ioctl(socketfd, SIOCGIFADDR, &ifr); char *address = inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr); but, on Windows, how can i achieve the same goal? (not using MFC) many thanks. edit: maybe my host has multiple ip addresses, and i want the one "connected" with

How to use data receive event in Socket class?

ぃ、小莉子 提交于 2019-12-08 09:04:38
问题 I have wrote a simple client that use TcpClient in dotnet to communicate. In order to wait for data messages from server i use a Read() thread that use blocking Read() call on socket. When i receive something i have to generate various events. These event occur in the worker thread and thus you cannot update a UI from it directly. Invoke() can be use but for end developer its difficult as my SDK would be use by users who may not use UI at all or use Presentation Framework. Presentation

Hunt down java.net.SocketException: No buffer space available

拈花ヽ惹草 提交于 2019-12-01 04:03:19
Hi I have very ugly problem with: java.net.SocketException: No buffer space available (maximum connections reached?) It is client-server app. Client is Windows XP SP2 32b, with two net cards core duo. Java 1.6. u7. Application have couple server socket open for local communication and couple of client socket for rmi to jboss server. After couple of hours/days! i am unable to open any new client socket to do communication to server. Server sockets still works. Windows netstat shows something from 130 to 150 connection. When manually trying I exhausted buffer after ~3500 connections! I tried: