Error Unable To Accept Connection To Server Socket Bad Address
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 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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Unable to receive data after connection getting Bad file Descriptor error up vote 1 down vote favorite I am working on a Multi-threaded Server application in C using Pthreads(Linux). My system is dual boot.Windows 7 as well as Ubuntu. I restarted my PC and booted into Windows from Ubuntu, Before restarting my server application was working Fine.After i again booted to ubuntu from windows. and started my server i start getting following Error when a client connects. recv failed: Bad file descriptor Here is My code: Main.C #include
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 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 http://stackoverflow.com/questions/30756210/unable-to-receive-data-after-connection-getting-bad-file-descriptor-error Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Calling accept() gives errorno 14 bad address up vote -1 down vote favorite I am creating a client and a server application and I am currently trying to establish http://stackoverflow.com/questions/26974179/calling-accept-gives-errorno-14-bad-address a connection. Whenever the client tries to connect to the server the server call to accept returns -1. When I examined the errno that was set from accept() it was 14 which stands for bad address. My code for creating the socket and accepting is as follows //create socket if((listenfd=socket(AF_INET,SOCK_STREAM,0))<0) { fprintf(stderr, "Cannot create server socket! errno %i: %s\n",errno,strerror(errno)); exit(-1); } //bind to the socket servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = htons(port); if( bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr))<0) { printf("Server bind failure errno %i: %s\n",errno,strerror(errno)); exit(-1); } // Turn 'listenfd' to a listening socket. Listen queue size is 5. if(listen(listenfd,5) < 0) { printf("Server listen failure errno %i: %s\n",errno,strerror(errno)); exit(-1); } while(1) { //accept connections if(newsock=accept(listenfd,(struct sockaddr*)&clientaddr,sizeof(clientaddr)<0)) { printf("Server accept failure errno %i: %s\n",errno,strerror(errno)); exit(-1); } int ch=fork(); if(ch<0) { printf("Fork failure errno %i: %s\n",errno,strerror(errno)); exit(-1); } else if (ch==0) { char buff[100]; int rc; rc=recv(listenfd,buff,sizeof(buff),0); if(rc<0) { printf("Receive failure err
Microsoft Tech Companion App Microsoft Technical Communities Microsoft Virtual Academy Script Center Server and Tools Blogs TechNet Blogs TechNet Flash Newsletter TechNet https://technet.microsoft.com/en-us/library/cc975827.aspx Gallery TechNet Library TechNet Magazine TechNet Subscriptions TechNet Video TechNet Wiki Windows Sysinternals Virtual Labs Solutions Networking Cloud and Datacenter Security Virtualization Downloads Updates Service Packs Security Bulletins https://publib.boulder.ibm.com/iseries/v5r1/ic2924/info/apis/accept.htm Windows Update Trials Windows Server 2012 R2 System Center 2012 R2 Microsoft SQL Server 2014 SP1 Windows 8.1 Enterprise See all trials » Related Sites Microsoft Download Center error unable TechNet Evaluation Center Drivers Windows Sysinternals TechNet Gallery Training Training Expert-led, virtual classes Training Catalog Class Locator Microsoft Virtual Academy Free Windows Server 2012 courses Free Windows 8 courses SQL Server training Microsoft Official Courses On-Demand Certifications Certification overview MCSA: Windows 10 Windows Server Certification (MCSE) Private Cloud Certification (MCSE) SQL Server Certification (MCSE) Other resources TechNet error unable to Events Second shot for certification Born To Learn blog Find technical communities in your area Support Support options For business For developers For IT professionals For technical support Support offerings More support Microsoft Premier Online TechNet Forums MSDN Forums Security Bulletins & Advisories Not an IT pro? Microsoft Customer Support Microsoft Community Forums United States (English) Sign in Home Library Wiki Learn Gallery Downloads Support Forums Blogs We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Windows 2000 Error Messages Reference Internet Information Services Internet Service Manager Internet Service Manager WINSOCK Error: Bad address.... WINSOCK Error: Bad address.... WINSOCK Error: Bad address.... WINSOCK Error: Socket is not connected.... Cannot load INETSTP.DLL. Please install from the Microsoft Internet Informa... Invalid Server Name... WINSOCK Error: ICMP network unreachable.... Setup cannot determine the remote machine's operation system type. Microsof... The specified CGI application misbehaved by not returning a complete set of... Gateway Error... Anonymous logon request received from user name at h
Authority: *USE Threadsafe: Yes The accept() function is used to wait for connection requests. accept() takes the first connection request on the queue of pending connection requests and creates a new socket to service the connection request. accept() is used with connection-oriented socket types, such as SOCK_STREAM. Parameters socket_descriptor (Input) The descriptor of the socket on which to wait. address (Output) A pointer to a buffer of type struct sockaddr in which the address from which the connection request was received is stored. The structure sockaddr is defined in