I am trying to locate all my sockets logically and I am having a hard time understanding.
Say, for example that I want them in this directory: /var/run/<app>/
I should specify uWSGI this in a command line parameter
--socket </var/run/<app>/>
However in my uwsgi.ini I have this:
socket = 127.0.0.1:3031
In order to get the effect I want, should I be doing
socket = /var/run/uwsgi
I am just confused, because one is an IP and one is a directory.
As documented you can use either network or Unix domain sockets.
Related
Im trying to download a file from a FTP server using active mode.However,it looks like my connection just"expire" or something each time.First,I open a port on my computer using netcat,ex:
nc -vv -l -p 62077
this will listen on port 62077 on my computer.Then,I open another netcat windows,log in to the FTP link using port 21,and once im in the directory where the file I want is in,I do
PORT (my IP separated by , ),(242,125(wich equals to port 62077)\r\n
However,after I enter this command,nothing happen for about 10-15 seconds,and the netcat just quit without saying anything.Nothing happen either on the netcat window that is listening on port 62077.It does that everytime,I dont know what I am doing wrong.I did the same thing with Filezilla(in active mode) and examinated the commands with wireshark,I do the exact same command as Filezilla,however filezilla will be able to retrieve the file while netcat wont.I want to retrieve it with netcat and I dont know what im doing wrong.I am using Windows 10.
thank you!
After you have established your listening nc socket, and after you have sent the USER, PASS, and PORT commands, you then need to trigger the file transfer to that listening socket using e.g.:
RETR /path/to/file/to/download
on the control connection. (Unless you actually are already doing this, but didn't mention it in the post?)
Also, just to note: you mention using something like this:
PORT 1,2,3,4,(242,125)\r\n
Right? Those parentheses might also be an issue. Instead, you might try:
PORT 1,2,3,4,242,125\r\n
without any parentheses.
Now, depending on the IP address you sent (hopefully not a private network address), the data transfer may still not happen, due to firewalls/routers/NAT on the client side of things. Given that your Filezilla download of the same file works, I suspect that those firewall/router/NAT issues may not apply.
Hope this helps!
I want to have a generic shell script which will check network connectivity between two hosts.
I wrote shell script with host and nslookup command to get the more details of target host, with these command I can't determine if current host can talk to target host.
Also I can't use(restricted) ping command , I was wondering if can use some other command to check network connectivity betweenn two hosts
Please suggest
Given a target host to determine if source host can communicate to target host
This is too vague to be useful. To solve this problem, you need to nail down what you mean by "communicate." A host may be able to send ICMP but not TCP. It may be able to send TCP but not ICMP. It may be able to send TCP to port 80, but not to 22. It may be able to send HTTP to port 80, but not SSH to port 80. Packets you send may return an error, or they may be silently dropped. The endpoint may receive your packets, but not process them. It may process them but not respond to you. There are many levels of "communicate."
So the best thing to test with is the thing you actually want to do. So if you want to communicate with HTTP over port 80, the best test is to do that. In fact, the best test is to just do the thing you wanted to do and not check beforehand. You're going to have to deal with errors no matter way. Just because you checked beforehand doesn't mean your actual attempt will be successful.
But sometimes you do just want to check "connectivity" (for some value of "connectivity") for monitoring purposes. In that case, again, do the thing you want. The easiest shell tool for checking HTTP connectivity is to fetch something with curl. If you need some other port, then a very nice generic solution is netcat (often called nc). I like:
nc -G 1 <host> <port> </dev/null
A return code of 0 means it connected; 1 means it failed.
For more esoteric issues, you can use nmap or even hping to craft about anything you want.
But most of the time, you shouldn't check at all. And if you do check, check with the thing you really want to do.
I'm using a REDIRECT iptables rule from my router(OpenWRT) to redirect certain UDP packets from the server A to the server B and I need to know how to get the original destination address(like a proxy).
I already found a lot of information on how to do this on Linux using TProxy and other methods but unfortunately I don't see how to use them on Windows, there is some alternative?
If you use the REDIRECT iptables target, the original destination IP address is overwritten. It is lost and cannot be recovered.
Also, iptables only runs on Linux, so your question about how to do this on Windows doesn't make sense.
I am new to socket programming. I'm tring to establish an UNIX domain socket with DATAGRAM. I look up the information about the configuration of sun_path in struct sockaddr_un for a while, seems like there are not enough sources to help me.
I created 3 files, unix_socket.c (provides an interface for socket connection), udp_server.c and udp_client.c, all are located in the directory "/home/Socket".
When I set the sun_path as "home/Socket", the server side always generates an error "Address already in use".
I also tried using "localSocket" and "echo_socket", but the client side always generates an error "No such file or directory".
I have no idea what's going on. Could anybody help me fix it? Really appreciate.
Thank you very much
The /home/Socket is already a folder, so it cannot be overwritten by a UNIX socket (think of it as a sort of a special file). Try another path like /home/Socket/mysocket.
You should also check out the bind(2) manpage and the example therein.
Is it possible to listen on a port and run a command when a user attempts to connect to that port? Ideal application is for a server that should only be run when someone is actually using it. Windows or Linux solutions work.
linux/unix:
man nc
NAME
nc - TCP/IP swiss army knife
some options that you may be interested
-l listen mode, for inbound connects
-p port local port number (port numbers can be individual or ranges: lo-hi [inclusive])
-e prog specify program to exec after connect (use with caution)
i think nc is also available under windows platform.
One solution could be via inetd or xinetd, specify the port number and a program to run, for you probably a shell script.
I am note sure what is the exact scope of a question but if bound to the programming-level, you could write your server in a way that when nobody is using it, no resources apart from the listening part are allocated. I would call it lazy initialization. When someone connects simply initialize the whole logic of your program. When all connections are gone, deinitialize everything.