Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux Socket 1

Status
Not open for further replies.

ostony

Programmer
Feb 21, 2001
20
US
Is there a way to determine if a socket is working correctly?

Thanks,
Tony
 
I'm not sure what you mean. Are you asking about how to determine this when you're doing sockets programming or how to determine if a port is actually responding such as port 25 for incoming mail?

GJ
 
Trying to determine if Mysql is connecting to the default port (3306). I get errors that it cannot connect, but I want be sure the socket is opening and closing correctly/
 
If you want to test if the socket is listening, just telnet to the server's IP address on port 3306. If telnet connects, then the socket is "working". That doesn't mean everything is configured correctly though, just that there is a program connected to that port via a socket and it is binding correctly. If you know the syntax for any of the communication, you could then type these to see if it responds with an appropriate response. For example, if you're testing a webserver, connect to port 80 and then type "get / http1.0" and hit return twice. You should see a stream of characters corresponding to the default webpage. If you do this to pop or smtp servers, they actually send out a greeting message first which makes it very clear that the server is functioning. Web servers (and I suspect MYSql) don't send out this welcome message so all you see is that it connected. In this case, you will have to know some of the communication syntax to see if the server is really working.

Hope this helps,
GJ
 
Thanks GJ. I've followed your instructions and my connection is lost immediately when I try to telnet to myserver 3306. Does this indicate that there's something wrong? Of course I'm not able to telnet into other ports either except for the natural telnet port.
 
I would think that indicates something is wrong. I would check to see if you have something like tcpwrappers interferring with your connection (assuming you're on linux). It's also possible that the application is disconnecting due to an internal error or misconfiguration. Also, I believe MySQl has the ability to limit connections to specific IPs. I would check to make sure this isn't the case as that would explain the dropped connection.

GJ
 
Thanks Again. I will see what I can find about tcpwrappers. The problem really stems from my linux box crashing because a cron ran off and opened about 300 mysqls. Don't know why it did. It's been working fine for a long time. Now all of a sudden I get an error message like: ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

This is not an uncommon error for Mysql users -- typically happens right after install, but like I said, mine was running fine and I have to think that the problem wasn't mysql, but rather this port not working correctly.

Do you think this is the correct logic?
 
If it's been running fine and then gets this error frequently after the crash, I would suspect corruption somewhere. If there are any utilities for checking the system databases, I would run them and then re-install as a last resort. If you have any backups of static files such as the shared libraries, I would restore those as a last resort before a re-installation.

GJ
 
If infact any libraries were corrupted, would it be indicated in the date of the file? Meaning would the file should up as being changed? Or is corruption possible without the date changing?
 
That's a good question and I really don't know the answer. I suspect that you could have situations that would cause it to happen both ways. I would think that you're more likely to have an updated time stamp than not but it's just a guess.

GJ
 
GunJack,

Got some more info about this problem. I ran a diagnostic tool on the Mysql databases, and got this error.

isamchk: Error reading file '/tmp/ST3TOJjx' (Errcode: 28)
Segmentation fault

Now that I think about it, I got a few of these errors prior to the crash. I understand it's a memory problem that is because the memory is not allocated to the program?

Or is it a hardware issue? Or was I hacked (I find no evidence of this).

Thanks again for all your help.

Tony

 
Hey Tony,

I believe segmentation faults are related to or sometimes related to memory allocation problems. It's possible that if the file is corrupt and the diagnostic tool doesn't properly check for errors, it could generate a segmentation fault. I would suspect corruption in this case over hacking as a hacker would usually target other areas and not specific data files.

I would try to find out what that file and any other corrupted files do and see if you can repair/rebuild/restore them.

Hope this helps,
GJ
 
Just as a last point on the memory issue. Got this info from 'top'. Does it look ok to you?

75 processes: 74 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 0.1% user, 0.3% system, 0.0% nice, 99.4% idle
Mem: 257744K av, 250008K used, 7736K free, 86568K shrd, 118916K buff
Swap: 265032K av, 20352K used, 244680K free 54604K cached
 
That looks normal to me based on what I see on my boxes but I'm not an expert in that area. I have been told that linux like to use up most of the memory and then make it available to programs that request it so I think it's normal for your memory utilization to be that high.

GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top