I am developing an IP sockets program for my final year Bsc (Hons) in Computing & Networks which is going to be used for the university robot project. I have the IP sockets program working and now I am trying to add some additions functions to the program which allows me to measure network performance related tests over a (LAN).
The tests will include sending/echoing bytes a number of bytes to the server and back. The tests will also need to show the time of how long it took to send & receive the message from the client & server respectively, the timing has to be measure milliseconds and to be able to calculate the the elasped time. The project needs to be in for the 28th August and I am not having much luck with it need all the assistance I can get, not a great programmer on C.
I have enclosed some coding below to show what the program currently looks like at the moment, This also includes my attempts of measuring the time when a message is received by the server, and my attempts to show the number of bytes sent. I desperately need help, any small piece of info you may have just might mke the difference. The coding is shown below for the client coding, this might take a little while to read.
int main()
{
// Initialize the winsock library
myTcpSocket::initialize();
// LARGE_INTEGER *lpPerformanceCount = (LARGE_INTEGER) new (sizeof
(LARGE_INTEGER));
LARGE_INTEGER lpPerformanceCount ;
// u_char cTTL
// CString str;
// get client's information (assume neither the name nor the address is given)
winLog << endl;
winLog << "Retrieve the localHost [CLIENT] name and address:" << endl;
myHostInfo clientInfo;
string clientName = clientInfo.getHostName();
string clientIPAddress = clientInfo.getHostIPAddress();
std::cout << "Name: " << clientName << endl;
std::cout << "Address: " << clientIPAddress << endl;
winLog << " ==> Name: " << clientName << endl;
winLog << " ==> Address: " << clientIPAddress << endl;
// get server's IP address and name
string serverIPAddress = "";
readServerConfig(serverIPAddress);
winLog << endl;
winLog << "Retrieve the remoteHost [SERVER] name and address:" << endl;
winLog << " ==> the given address is " << serverIPAddress << endl;
// connect to the server.
std::cout << "connecting to the server [" << serverName << "] ... " << endl;
winLog << "connecting to the server [" << serverName << "] ... " << endl;
myClient.connectToServer(serverIPAddress,ADDRESS);
int recvBytes = 0;
while (1)
{
// send message to server
char messageToServer[MAX_MSG_LEN+1]= "hello world2";
//char senddata(socketId,buf,MAX_MSG_LENGTH,0);
//memset(messageToServer,0,sizeof(messageToServer));
std::cout << "[SEND] ";
std::cin.getline(messageToServer,MAX_MSG_LEN);
//memset(messageToServer,0,sizeof(senddata));
std::cout << " %s [%s]with %d bytes of data:";
std::cout << strlen(messageToServer);
//###########################################
char tmpbuf[128], timebuf[26];
time_t ltime;
string mystr;
mystr="ABC";
// time( <ime );
QueryPerformanceCounter( &lpPerformanceCount);
std::cout<<( "Time in something:=%ldms,TTL=%d", &lpPerformanceCount);
//Removing getline so we that we don't need to wait for input //std::cin.getline
// (messageToServer,MAX_MSG_LEN);
GetTickCount() returns a 32-bit integer representing the number of milliseconds since the program was started. GetTickCount64() does the same but returns an ULONGLONG. Whatever that is.
As far as I can remember, long long is only signed, not unsigned.
Well, it doesn't matter much. I don't think the program will be running for 292277024,66 years, so that extra bit isn't too important.