turbot_yu
asked on
slow down by socket
Hi Experts,
After I add a simple socket client code to my original program, the original one seems slow down.
The original one is used to upload data from one DB to another.
And the code for socket is just to send several strings.
Have I missing somewhere to make the speed low, originally the upload speed is quite fast.
Thanks and Regards,
Turbot
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
printf("Error at WSAStartup()\n");
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( m_socket == INVALID_SOCKET ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
//return;
}
else{
// Connect to a server.
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_a ddr = inet_addr( IP_ADDRESS_PQHUB );
clientService.sin_port = htons( PORT_PQHUB );
if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
WSACleanup();
//return;
}
else {//connection is successful
bytesSent = send( m_socket, sendbuf, strlen(sendbuf), 0 );
printf( "Bytes Sent: %ld, %s \n", bytesSent, sendbuf );
WSACleanup();
}
}
After I add a simple socket client code to my original program, the original one seems slow down.
The original one is used to upload data from one DB to another.
And the code for socket is just to send several strings.
Have I missing somewhere to make the speed low, originally the upload speed is quite fast.
Thanks and Regards,
Turbot
// Initialize Winsock.
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
printf("Error at WSAStartup()\n");
// Create a socket.
SOCKET m_socket;
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
if ( m_socket == INVALID_SOCKET ) {
printf( "Error at socket(): %ld\n", WSAGetLastError() );
WSACleanup();
//return;
}
else{
// Connect to a server.
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_a
clientService.sin_port = htons( PORT_PQHUB );
if ( connect( m_socket, (SOCKADDR*) &clientService, sizeof(clientService) ) == SOCKET_ERROR) {
printf( "Failed to connect.\n" );
WSACleanup();
//return;
}
else {//connection is successful
bytesSent = send( m_socket, sendbuf, strlen(sendbuf), 0 );
printf( "Bytes Sent: %ld, %s \n", bytesSent, sendbuf );
WSACleanup();
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.