Skip to main content
added 38 characters in body
Source Link
Loki Astari
  • 96.6k
  • 5
  • 125
  • 338

Some issues that occur to me:

  • The obvious problem is that there is no error checking.

  • memset is often preferred to bzero, although I don't see why. Also the cast of serverAddr to char* in the bzero call is unnecessary.

  • port number should be shared in a header file

  • is inet_addr the correct way to get the address? Also note that it, too, can fail. And there is usually an memcpy involved in creating the address structure.

  • does calling shutdown have any purpose?

  • putting a 1k buffer on the stack would be a bad idea in some small systems

  • the issue of read not returning all of what was written (or being interrupted) was already mentioned. Also read returns ssize_t not int or size_t.

  • finished variable is redundant.

Trivia

  • Usage message might use argv[0] instead of assumed executable name. Also the host must be a dotted address not a name.

  • exit status might prefer EXIT_FAILURE

  • I'd put "Response from server" in the format string.

Some issues that occur to me:

  • The obvious problem is that there is no error checking.

  • memset is often preferred to bzero, although I don't see why. Also the cast of serverAddr to char* in the bzero call is unnecessary.

  • port number should be shared in a header file

  • is inet_addr the correct way to get the address? Also note that it, too, can fail. And there is usually an memcpy involved in creating the address structure.

  • does calling shutdown have any purpose?

  • putting a 1k buffer on the stack would be a bad idea in some small systems

  • the issue of read not returning all of what was written (or being interrupted) was already mentioned. Also read returns ssize_t not int or size_t.

Trivia

  • Usage message might use argv[0] instead of assumed executable name. Also the host must be a dotted address not a name.

  • exit status might prefer EXIT_FAILURE

  • I'd put "Response from server" in the format string.

Some issues that occur to me:

  • The obvious problem is that there is no error checking.

  • memset is often preferred to bzero, although I don't see why. Also the cast of serverAddr to char* in the bzero call is unnecessary.

  • port number should be shared in a header file

  • is inet_addr the correct way to get the address? Also note that it, too, can fail. And there is usually an memcpy involved in creating the address structure.

  • does calling shutdown have any purpose?

  • putting a 1k buffer on the stack would be a bad idea in some small systems

  • the issue of read not returning all of what was written (or being interrupted) was already mentioned. Also read returns ssize_t not int or size_t.

  • finished variable is redundant.

Trivia

  • Usage message might use argv[0] instead of assumed executable name. Also the host must be a dotted address not a name.

  • exit status might prefer EXIT_FAILURE

  • I'd put "Response from server" in the format string.

Source Link
William Morris
  • 9.2k
  • 18
  • 42

Some issues that occur to me:

  • The obvious problem is that there is no error checking.

  • memset is often preferred to bzero, although I don't see why. Also the cast of serverAddr to char* in the bzero call is unnecessary.

  • port number should be shared in a header file

  • is inet_addr the correct way to get the address? Also note that it, too, can fail. And there is usually an memcpy involved in creating the address structure.

  • does calling shutdown have any purpose?

  • putting a 1k buffer on the stack would be a bad idea in some small systems

  • the issue of read not returning all of what was written (or being interrupted) was already mentioned. Also read returns ssize_t not int or size_t.

Trivia

  • Usage message might use argv[0] instead of assumed executable name. Also the host must be a dotted address not a name.

  • exit status might prefer EXIT_FAILURE

  • I'd put "Response from server" in the format string.