ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i have two computers connected onto a network here at work. I want to run my server.c on one computer and get a response from client.c. This works fine with localhost and using two terminal screens.........one for the server and other for the client. But it does not work if i run the server program on another computer. How can i fix this.....what are the steps involved in doing this. Here are my programs(very simple).
void main(int argc,char *argv[])
{
struct sockaddr_in pin;
struct sockaddr_in sin;
int sock_descriptor;
int temp_sock_descriptor;
int address_size;
char buf[16384];
int i, len;
sock_descriptor = socket(AF_INET,SOCK_STREAM,0);
if(sock_descriptor == -1){
perror("call to socket");
//exit(1);
}
//char *str = "A default test string";
Your client connects to a hardcoded IP address. Is that the address of the computer where the server app runs?
Maybe a firewall that blocks access to port 8000? Can you telnet to the server-PC on port 8000 (telnet hostaddr 8000)?
Can you ping the server PC from the client PC?
What is that xxx in host_name in the client app? (just hiding details for us?)
I can telnet my default gateway........but not this other pc. I tried to run the telnet server service on the other pc but it got stopped for some reason and wouldn't allow it.
run your server app on the second PC (and the client as well);
1)
Use localhost
Works? if yes, next step
2)
Use ip-address xxx.16.13.124 (server and client still running on same PC)
Works? if yes, next step
3)
Use the 2 pc's, one running client and other running server
We know that the one way does not work (client on PC1, server on PC2);
does the other way work?
Still guess you have a firewall issue that blocks access to the port.
BTW, you don't need a telnet server to test what I suggested earlier on. You 'simply' telnet into the server app (telnet localhost 8000 and telnet xxx.16.13.124 8000). Your server app must obviously be running.
Last edited by Wim Sturkenboom; 09-29-2005 at 01:33 AM.
Thanks alot for your responses. You have been very helpful. I should be able to resolve this issue now. I am quite sure that you are right. I done the telnet in both directions but no luck and i used the same syntax you used above
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.