Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9116119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:35:42+00:00 2026-06-17T04:35:42+00:00

hello i have a client socket application, that connect at the same time, with

  • 0

hello i have a client socket application, that connect at the same time, with more than 5000 server with tcpip in linux, but when i open the socket connection, almost all connections, retrieve the error Operation now in progress.

Here my client socket connect code:
how can i doing a good thousands simultaneously socket conecction at the same time???
sorry for my english.
here my code :

struct sockaddr_in echoserver;
struct sockaddr_in sa_loc;
char aport[64];
int optval = 1;
int sock;

memset(&echoserver, 0, sizeof (echoserver));
echoserver.sin_family = AF_INET;  
echoserver.sin_addr.s_addr = inet_addr(server.c_str()); 
echoserver.sin_port = htons(0);     

SOCKET = socket(AF_INET, SOCK_STREAM, 0);
if (SOCKET == -1)
{
 iLastError = errno;
 strLastError = "Create socket Error : "+string(strerror(errno)); 
 connected = false;
 return connected;
}

struct timeval timeouts, timeoutr;
memset(&timeouts, 0, sizeof(timeouts)); // zero timeout struct before use
timeouts.tv_sec = SendTimeOut/1000;
timeouts.tv_usec = 0;
memset(&timeoutr, 0, sizeof(timeoutr)); // zero timeout struct before use
timeoutr.tv_sec = ReceiveTimeOut/1000;
timeoutr.tv_usec = 0;   
int sockopt = setsockopt(SOCKET, SOL_SOCKET, SO_SNDTIMEO, &timeouts, sizeof(timeouts)); 
if (sockopt == -1) 
{
 printf("%s%s","Set socket Option error : ",strerror(errno));
 iLastError = errno;
 strLastError = "setsockopt Error : "+string(strerror(errno));
}
sockopt = setsockopt(SOCKET, SOL_SOCKET, SO_RCVTIMEO, &timeoutr, sizeof(timeoutr)); // 
if (sockopt == -1) 
{
   printf("%s%s","Set socket Option error : ",strerror(errno));
   iLastError = errno;
   strLastError = "setsockopt Error : "+string(strerror(errno));
}

memset(&sa_loc, 0, sizeof(struct sockaddr_in));
sa_loc.sin_family = AF_INET;
sa_loc.sin_port = htons(0);  //8000
sa_loc.sin_addr.s_addr = inet_addr(SourceIP.c_str());
int bindid = bind(SOCKET, (struct sockaddr *)&sa_loc, sizeof(sa_loc));
if (bindid !=0) 
{
 iLastError = errno;
 strLastError = "Bind Error : "+string(strerror(errno));    
}

int conn = connect(SOCKET, (struct sockaddr *) &echoserver, sizeof(echoserver));

if (conn == -1)
{
 strLastError = "Connect Error : "+string(strerror(errno));   
 connected = false;
}
else {
 connected = true;
}

return connected;

wpp

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:35:43+00:00Added an answer on June 17, 2026 at 4:35 am

    if your variable SendTimeOut is < 1000 then your recv timeout will be 0, and I’m not sure if that is the same as setting O_NONBLOCK, but if it is then it sounds like this is normal process, and you should loop until it succeeds (or you get EISCONN) or fails with a different error code. If this is intended you should probably just set O_NONBLOCK explicitly.

    http://linux.die.net/man/3/connect

    EINPROGRESS
    O_NONBLOCK is set for the file descriptor for the socket and the connection cannot be immediately established; the connection shall be established asynchronously.

    …

    If the connection cannot be established immediately and O_NONBLOCK is set for the file descriptor for the socket, connect() shall fail and set errno to [EINPROGRESS], but the connection request shall not be aborted, and the connection shall be established asynchronously. Subsequent calls to connect() for the same socket, before the connection is established, shall fail and set errno to [EALREADY].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For learning purposes I am writing a socket based client/server application. I have designed
For learning purposes I am writing a socket based client/server application. I have designed
I have server and client code that works perfectly as a Java application. The
hello I have my code that connects to my ftp server $conn_id = ftp_connect($ftp_server);
I have a simple programs for socket client and server its not working over
i have written simple client server socket programming code as follow MyServer.java import java.io.DataInputStream;
i have to create connecting server<=>client. I use this code: Server: import socket HOST
I have a socket server running on an android device. Then from a client
I have a client-server application, in the client side i have a button to
Hello guys have client server chat and i try to write load test on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.