Solved

client-server demo

Posted on 2000-04-07
1
211 Views
Last Modified: 2010-04-15
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
Comment
Question by:katzgal
1 Comment
 
LVL 2

Accepted Solution

by:
munsie earned 100 total points
ID: 2695214
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question