LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-07-2009, 07:30 AM   #1
ZuzooVn
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Rep: Reputation: 0
Question Client & server program


Hi everybody
I find the code of Client - server program

Server.C: http://paste.ubuntu.com/334989/
Client.C: http://paste.ubuntu.com/334993/

I can use it to exchange some message between to different shell windows. But i can't run the client program on one machine, and server program on the other machine so that it can exchange some messages.

Can you help me.

Thank you very much!

Last edited by ZuzooVn; 12-07-2009 at 10:09 AM.
 
Old 12-07-2009, 08:41 AM   #2
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
I am by no means an expert in this field but I have downloaded and built your example programs and ran them. They pass messages between different machines fine for me. It may help if you say exactly what you are entering to run the programs (both ends) and what results you are getting. You should provide these for when things work and do not work for completeness.
 
1 members found this post helpful.
Old 12-07-2009, 10:06 AM   #3
ZuzooVn
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bgeddy View Post
I am by no means an expert in this field but I have downloaded and built your example programs and ran them. They pass messages between different machines fine for me. It may help if you say exactly what you are entering to run the programs (both ends) and what results you are getting. You should provide these for when things work and do not work for completeness.
I run it successful in a computer.
In one terminal, i type: ./receiver
In other terminal, i type ./sender 127.0.0.1 message <127.0.0.1 : localhost >
./sender <hostname> <message>

And my problems here is:

I install Ubuntu 9.10 on VMware Workstation. I using my university's networks via HTTP proxy: Proxy and port: 8080.

Can u tell me, how can i find hostname in "sender <hostname> <message>"

Thank you very much
 
Old 12-07-2009, 03:22 PM   #4
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
Can u tell me, how can i find hostname in "sender <hostname> <message>"
I'm not sure what you mean here.

Here's what I did.. On one machine I typed "/server" for the "receiver" end. This is the program built from your "server.c" source code.
On another I ran "/client 192.168.1.6 'Hello from client' " where 192.168.1.6 is the IP of the machine running the server program. Note that the message needs enclosing in quotes or the client program errors out. For me this works between machines or between terminals on the same machine using localhost as the hostname.

To try and replicate your setup I have also tried running this in a Linux Virtual machine inside VMWare. This too works fine. I have the VM set to use bridged networking and it gets it's own unique IP via DHCP from the network DHCP server. In effect this means the VM just looks like another workstation on the network. I can run two such VM's and communicate between both using your programs or between the host and the VM's.

If you wish to find the IP of the Ubuntu VM you can run "ifconfig". You may use this as the hostname for the programs.

Before you worry about two networked machines passing messages via your code I would try pinging each one from the other one to make sure they can see each other across the network and that your IP's are correct.
 
1 members found this post helpful.
Old 12-08-2009, 11:29 AM   #5
ZuzooVn
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bgeddy View Post
I'm not sure what you mean here.

Here's what I did.. On one machine I typed "/server" for the "receiver" end. This is the program built from your "server.c" source code.
On another I ran "/client 192.168.1.6 'Hello from client' " where 192.168.1.6 is the IP of the machine running the server program. Note that the message needs enclosing in quotes or the client program errors out. For me this works between machines or between terminals on the same machine using localhost as the hostname.

To try and replicate your setup I have also tried running this in a Linux Virtual machine inside VMWare. This too works fine. I have the VM set to use bridged networking and it gets it's own unique IP via DHCP from the network DHCP server. In effect this means the VM just looks like another workstation on the network. I can run two such VM's and communicate between both using your programs or between the host and the VM's.

If you wish to find the IP of the Ubuntu VM you can run "ifconfig". You may use this as the hostname for the programs.

Before you worry about two networked machines passing messages via your code I would try pinging each one from the other one to make sure they can see each other across the network and that your IP's are correct.
I am so sorry. But i follow you and step to step in VMware.
I have Ip of each computer by run "ifconfig" on each computer.
But when i ping each one from the other one, I have a error: Destination Host Unreachable

I don't know the reason why i can't do it. So sad.

Would you please print screen on each step to tell me how to use this program in correctly way (i'm sorry about it because may be you're very busy.)

Thank you very much
 
Old 12-09-2009, 06:39 AM   #6
ZuzooVn
LQ Newbie
 
Registered: Dec 2009
Posts: 4

Original Poster
Rep: Reputation: 0
i ping each one from the other one successfully
But i can't sent message between 2 computer (
i don't know the reason
 
  


Reply

Tags
client, program, server


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please post simple & working configuations Server and Client for KERBEROS,& TUTORIAL frenchn00b Debian 4 09-20-2009 09:44 AM
server client program swift2008 Programming 10 11-26-2008 01:12 PM
How to get IP address of client from server.c program nazsarwat Programming 1 04-22-2005 04:57 PM
NIS server && client issue LinuxRam Linux - Networking 1 11-03-2004 12:14 PM
Server Client program using UDP frostmagic Programming 9 11-15-2003 12:06 AM


All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration