Tag Info

Hot answers tagged

85

/etc/init.d/networking restart Let me elaborate. Transmission Control Protocol (TCP) is designed to be a bidirectional, ordered, and reliable data transmission protocol between two end points (programs). In this context, the term reliable means that it will retransmit the packets if it gets lost in the middle. TCP guarantees the reliability by sending back ...


42

I don't know if you have the source code of that particular program you're running, but if so you could just set SO_REUSEADDR via setsockopt(2) which allows you to bind on the same local address even if the socket is in TIME_WAIT state (unless that socket is actively listening, see socket(7)). For more information on the TIME_WAIT state see the Unix socket ...


26

As far as I know there is no way to forcibly close the socket outside of writing a better signal handler into your program, but there is a /proc file which controls how long the timeout takes. The file is /proc/sys/net/ipv4/tcp_tw_recycle and you can set the timeout to 1 second by doing this: echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle However, this ...


14

Use an IP-binding to 127.0.0.1 that should activate a listening port on "localhost". On the client side do not use "localhost" - use "127.0.0.1" instead. Many clients have an internal alias that makes them connect to the socket if you specify "localhost" as target. mySQL is strange.


14

You should have a location section to handle PHP requests configured similarly to this: location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } ...


14

You can try to use the iftop command. It provides a nice curses display. This can show realtime and average statistics for an interface or specific source/destination/port. It can can also filter, but I haven't explored that functionality. Host display: General: n - toggle DNS host resolution P - pause display s - toggle ...


11

Yes, this is a valid way to check that the socket is non-blocking. The value for a non-blocking socket is 04000, non-blocking sockets in /proc/<pid>/fdinfo are represented in octal. You can validate this behaviour with python. Python 2.7.5 (default, Feb 19 2014, 13:47:28) [GCC 4.8.2 20131212 (Red Hat 4.8.2-7)] on linux2 Type "help", "copyright", ...


11

That port range is not supposed to be programmer defined. It is reserved by IANA, The Well Known Ports are those from 0 through 1023. DCCP Well Known ports SHOULD NOT be used without IANA registration. The registration procedure is defined in [RFC4340], Section 19.9. For differing opinions check, From a linuxquestions thread (read at the link ...


10

i haven't done this, but i would try with socat. maybe something like: ssh xxx@yyy.zzz -L 9999:localhost:9999 "socat TCP-LISTEN:localhost:9999 UNIX-CONNECT:/var/run/mysqld/mysql.sock" socat UNIX-LISTEN:/path/to/local/socket TCP:localhost:9999 again, i have never done anything like this.


10

This can occur if you create a socket, but never connect() or bind() with it. Your best bet may be to strace (-fF) the application, and then cross-reference with the output of lsof to determine which sockets are causing the issue. As a bonus method of debugging: if you wrap your socket calls with debugging information and write them out to /dev/null, it'll ...


9

By default, when both tcp_tw_reuse and tcp_tw_recycle are disabled, the kernel will make sure that sockets in TIME_WAIT state will remain in that state long enough -- long enough to be sure that packets belonging to future connections will not be mistaken for late packets of the old connection. When you enable tcp_tw_reuse, sockets in TIME_WAIT state can be ...


9

Actually there is a way to kill a connection - killcx. They claim it works in any state of the connection (which I have not verified). You need to know the interface where communication happens though, it seems to assume eth0 by default. UPDATE: another solution is cutter which comes in some linux distros' repositories.


7

In Linux and other *nixes, MySQL will assume you want to use a socket if you connect to the host "localhost" (which would be the default hostname). You can override this in 3 ways: 1) Specify a different hostname like 127.0.0.1 (mysql -h 127.0.0.1) or your server's real hostname 2) Specify that you want to use TCP and not a socket (mysql --protocol tcp) ...


7

It's not a TCP requirement. As far as TCP is concerned, only the combination of source IP, source port, destination IP, and destination port needs to be unique. However, in practice most TCP APIs don't provide any way to create more than one connection with the same source port, unless they have different source IP addresses.


7

This is a setting in your TCP stack. Since we don't know what platform you're on we can't say exactly what it's called and how to change it. UPDATE So you're using Ubuntu. You can use sysctl to reduce the net.inet.tcp.msl value to half the desired TIME_WAIT duration (in milliseconds -- see man -S 4 tcp), e.g. sysctl net.inet.tcp.msl=2500. Beware of the ...


7

I ususally use iptraf for things like this: This screen shows a bunch of database connections, but you can filter for whatever you're interested in.


6

Yes, we call them network connections. Everything you do on the Internet uses them. Aside from the AF_UNIX socket you are referring to, there are AF_INET sockets and AF_INET6 sockets, which make IPv4 and IPv6 connections, respectively. There are a few other types, but you probably don't care about ancient things like AppleTalk... Unlike Unix sockets, ...


6

One thing you might check is (which requires you to login to the MySQL console) - check to make sure that you have permissions to login to root via localhost. mysql -h 127.0.0.1 -u root -p -- Once you have successfully logged in -- mysql> select user,host from mysql.user; +------+--------------------------------+ | user | host ...


6

Forward a local socket on demand Setup SSH public key authentication Install socat at both ends create a directory locally for your sockets, inaccessible to other users. export SOCKET_DIR=~/.remote-sockets socat "UNIX-LISTEN:$SOCKET_DIR/mysqld.sock,reuseaddr,fork" \ EXEC:'ssh user@server socat STDIO UNIX-CONNECT\:/var/run/mysqld/mysqld.sock' then ...


6

You can safely reduce the time down, but you may run into issues with inproperly closed connections on networks with packet loss or jitter. I wouldn't start tuning at 1 second, start at 15-30 and work your way down. Also, you really need to fix your application. RFC 1185 has a good explanation in section 3.2: When a TCP connection is closed, a delay ...


6

A socket file doesnt actually contain data, it transports it.. It is a special, unusual type of file created with special system calls/commands. It is not an ordinary file. It is like a pipe the server and the clients can use to connect and exchange requests and data. Also, it is only used locally. Its significance is merely as an agreed rendezvous ...


6

A socket is a special pseudo-file used for data transmission by reading and writing, not data storage. The socket file is created when the service is started and removed when the service is terminated. The location of the file is defined in /etc/my.cnf like so: [mysqld] socket=/var/run/mysql/mysql.sock


6

Isn't this really a client issue ? If using the mysql program You can use the --protocol switch. From the man page --protocol={TCP|SOCKET|PIPE|MEMORY} The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. ...


5

Usually, root access is needed to open ports under 1024, which covers most of the well known services such as web (80), ssh (22), ftp (21) etc. Some daemons can be configured to listen on other ports above port 1024 which might let you use them with non-root permissions, but it varies on a product by product basis. There are other work arounds as well, ...


5

While you most likely could set Nginx to proxy redirect to a socket using unix:/path/to/socket syntax, Apache Listen directive only accepts IPv4 or IPv6, so as far as I know you can't get Apache to listen on an unix socket.


5

This doesn't answer your question (and it's 18 months late), but suggests another way of making your legacy app reuse ports: A useful alternative to setting tcp_tw_reuse (or tcp_tw_recycle) on the system is to insert a shared library (using LD_PRELOAD) into your app; that library can then allow reuse of the port. This makes your legacy app allow port reuse ...


5

In this context a socket is a spot on the motherboard for a CPU. This has room for 4 CPUs total. http://en.wikipedia.org/wiki/CPU_socket


5

The server is "2-way" because it contains two Xeon E5-2670's. These are 8-core CPUs with hyper-threading, so the server would have 16 physical cores and 32 virtual cores. I believe the DL380p always has two sockets.


4

I don't have a host that I can ssh to and control whether it's up or not, but this should work: while ! ssh <ip> do echo "Trying again..." done Or a shell script that is more explicit: #!/bin/sh ssh $1 while test $? -gt 0 do sleep 5 # highly recommended - if it's in your local network, it can try an awful lot pretty quick... echo "Trying ...


4

You can close a socket in sh just like any other file: exec 42>&- where 42 is the file descriptor. What you can't do (except in a few shells that provide an extension for it) is open a socket. But of course that closes the socket in the shell, not in another process. Closing a socket in a running process would disrupt its behavior in a way that the ...



Only top voted, non community-wiki answers of a minimum length are eligible