Solved

client-server demo

Posted on 2000-04-07
1
202 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now