Polling Error 10049
Contents |
Forum Visual C++ & C++ Programming Network Programming Socket connect error 10049 If this is your first visit, be sure to check out the FAQ by clicking socket error 10038 the link above. You may have to register or Login before you can post:
Socket Error Codes Linux
click the register link above to proceed. To start viewing messages, select the forum that you want to visit from
Socket Error 10054 Connection Reset By Peer
the selection below. Results 1 to 2 of 2 Thread: Socket connect error 10049 Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode
Socket Error 10049
Switch to Threaded Mode October 29th, 2008,05:35 AM #1 pobri19 View Profile View Forum Posts Junior Member Join Date May 2008 Posts 15 Socket connect error 10049 Hi, so I'm learning socket programming in Windows XP. I'm trying to set up a simple server/client interaction, but I can't seem to get it working. Whenever I run the client, I get a "Socket connect error 10049" message printed socket error 10053 to the console (meaning WSAGetLastError() is returning the error number 10049). Error 10049 translates to: Code: WSAEADDRNOTAVAIL 10049 0x2741 The requested address is not valid in its context. NOTE: The key part of the code that's causing the trouble is at the bottom of the code if you don't want to read all of that. Here's the code of the client: Code: #include
360 games PC games socket error 11004 Windows games Windows phone games Entertainment All Entertainment winsock error 10054 fix Movies & TV Music Business & Education Business Students & educators windows socket error windows 10 Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet http://forums.codeguru.com/showthread.php?464152-Socket-connect-error-10049 Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All https://support.microsoft.com/en-us/kb/819124 Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site http://stackoverflow.com/questions/39066799/what-causes-error-in-the-poll-function-c About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What causes error in socket error the poll() function, c++? up vote 2 down vote favorite I'm fairly new to socket programming, and I'm trying to write a program that would get incoming tcp connections and manage them somehow. I can't figure out why the following code is giving me a "poll error": int main(int argc, char *argv[]) { char *port; struct pollfd connections[MAX_CONNECTIONS]; struct addrinfo addr_hints, *addr_result; int ret, i; polling error 10049 for (i = 0; i < MAX_CONNECTIONS; ++i) { connections[i].fd = -1; connections[i].events = POLLIN; connections[i].revents = 0; } port = "0"; memset(&addr_hints, 0, sizeof(struct addrinfo)); addr_hints.ai_flags = AI_PASSIVE; addr_hints.ai_family = AF_UNSPEC; addr_hints.ai_socktype = SOCK_STREAM; addr_hints.ai_protocol = IPPROTO_TCP; getaddrinfo(NULL, port, &addr_hints, &addr_result); connections[0].fd = socket(addr_result->ai_family, addr_result->ai_socktype, addr_result->ai_protocol); if (connections[0].fd < 0) { cerr << "Socket error" << endl; return 0; } if (bind(connections[0].fd, addr_result->ai_addr, addr_result->ai_addrlen) < 0) { cerr << "Bind errror" << endl; return 0; } if (listen(connections[0].fd, 25) < 0) { cerr << "Listen error" << endl; return 0; } do { for (i = 0; i < MAX_CONNECTIONS; ++i) connections[i].revents = 0; ret = poll(connections, MAX_CONNECTIONS, -1); if (ret < 0) { cerr << "Poll error" << endl; return 0; } else { //DO SOMETHING } } while(true); } MAX_CONNECTIONS is a constant set to 10000. Connections[0] is supposed to be the descriptor on which i am listening to incoming connections. I set port to "0" because i want to pick a random port. It seems that the poll function fails immediately, yielding the message "Poll error" (so poll() was less than 0 basically). I've checked and after poll and