TCP Server Source Code throwing an exeception

As mentioned in the Program for Server section of this:

I changed the IP Address and port number. I’m not sure if something is not being initialized properly, but I get an exception. Attached is a VS Debug screenshot of the point where the exception is thrown. Any help would be greatly appreciatedalt text

It should be:
scanf_s(“%s”, sendBuffer);
instead of
scanf_s(“%s”, &sendBuffer);
It seems that there was a typo in the code.

Hello,

Thanks for the answer. I tried that last night, but doesn’t seem to work unfortunately. Please see the attached image for a log from the debug output window

Best,
Karthik

alt text

However this works:

  1. Initialize a new pointer (For example, char* test = new char[BUFFER_SIZE];
    And after
    scanf_s(“%s”, &sendbuffer);

strcpy(test, sendbuffer);
int new_len = strlen(test);
retVal = send(commsocket, test, new_len, 0);

Caveat: The capability of reading the sendbuffer at the client side depends upon how the client handles the sendbuffer (For example, the client may expect a carriage return followed by a line feed. In that case “\r\n” needs to be added to the end of test string and new_len changed accordingly).

Best,
Karthik