LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-11-2002, 01:49 PM   #1
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Rep: Reputation: 31
error connecting to socket


hello there

i have a problem in c: i can set up a socket connection to another pc (on my lan) and then send messages and read from the remote site too. this works fine.

but when i try to connect to a host that is not on my lan (but connected trough a ppp interface) then i get a really weird error message:

it says:

error connectiong to host: Succes



the line that makes this happen is:

perror("error connecting to host");

and is only processed if the remote computer cannot be reached... (pointer equals NULL)
why does it say then "Success"?????? if i try to connect to a remote host that has no service i wish to access the error message says connection refused. that is ok.

do i have to care about routing explicitly in my program? (routing works fine) or why do i get this message???



any help is welcome

raven
 
Old 02-11-2002, 06:20 PM   #2
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
Re: error connecting to socket

The perror() function depends on the setting of the "errno" global variable (defined in "errno.h"). When you call perror("xxx"), it will print your message followed by a colon and a blank and then print text describing the error number that is in errno. If errno is zero, it prints "Success". errno is only good until the next system call. Did you do something else between the detection of the null pointer and the perror()
call?
 
Old 02-12-2002, 12:47 PM   #3
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 31
hello

i did no do anything between the connection attempt and the error message.

i know how perror works, and thets why i wonderes about the outcomes...

btw: this error only happens when i connect to one host. i tryed another one recently, and there i had absolutely no pbroblems...

i wonder what the other machine was doing...

thanks anyway.

any further suggestion?

raven
 
Old 02-14-2002, 01:07 PM   #4
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 31
It would be best if you included a sniplet of code.

At least a few lines before and after the connect() call.

Maybe the host is behind a firewall? Can you ping it? telnet to that port?
 
Old 02-14-2002, 04:56 PM   #5
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 31
thanks alot. but the problem is solved now. i still dont know why it didnt work, but now it works.

secrets of coding :-)

thanks anyway :-)

bye

raven
 
  


Reply



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
PHP5-MySQL Not Connecting Through Socket oxblood Linux - Software 5 03-15-2010 05:53 PM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 07:28 PM
While connecting to session manager: Could not open network socket mrmailer Fedora 0 08-10-2004 04:55 AM
socket error adoyee Programming 3 02-07-2004 11:11 AM
Socket:Connecting to Known services karthikavk Programming 0 12-06-2001 02:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:52 PM.

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
Open Source Consulting | Domain Registration