• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

client-server demo

I need to write a simple tcp/ip client-server application where the client gets the server address and an exec to run as parameters and sends the exec to the server which runs itand returns the exit status of the exec.
if someone can give me a simple code to start with i'm sure to be able to continue from there.
oh and the server and client suppose to work on both unix and win95 (i was told it is different).
0
katzgal
Asked:
katzgal
1 Solution
 
munsieCommented:
this almost sounds like a school assignment....

anyway for some pointers, since that is what you are looking for, go grab a copy of Unix Network Programming Vol 1 by Richard W. Stevens.

A few pointers on making your source code work under Unix and Windows:

1. Unix uses ints for socket descriptors, Windows uses the SOCKET type:

so do the following:

#if defined unix
typedef SOCKET int;
#endif

2. Unix allows you to use read() and write() on a socket, Windows does not.

so, just use recv() and send()

3. Windows use WSGetLastError() to return errors, Unix uses errno.

again you can just define a macro:

#if defined unix
#define WSGetLastError() errno
#endif

that should cover most of the differences.  Look in the Visual C++ documentation for more info, but for simple TCP networking that should cover it.

i haven't found any books that cover both Unix and Windows networking, but the Unix Network Programming book will give you enough background in Unix to make the transition to Windows fairly easy.

good luck,
dennis
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now