How to configure the path for the UDP on the UNIX domain socket? - linux-kernel

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.

Related

Problem with listing FTP file names on M66 OpenCPU with AT+QFTPNLST

I have a hardware with quectel M66 module. I am also using the module as main processing unit, so the default Opencpu is quite changed. Also there is a watchdog applied to the module.
I am trying to open an FTP connection and get the file list on FTP with AT+QFTPNLST
opened connection with
AT+QIFGCNT=0
AT+QFTPUSER="---"
AT+QFTPPASS="---"
AT+QFTPOPEN="---",---
AT+QFTPPATH="/"
AT+QFTPCFG=4,"/COM/"
AT+QFTPNLST
FTP connection opens without problems (AT+QFTPSTAT returns OPENED). I can read, get, put etc. on FTP.
AT+QFTPNLST returns OK, CONNECT, and +QFTPNLST:1 but not the file name list. then the device goes to restart (because of the watchdog).
Any ideas why that happens?
thanks.

Golang `pions` lib example issue

I've just started experimenting with WebRTC with Go and downloaded pions/webrtc library but I'am stuck with it's data-channels example.
As it written in docs I opened jsfiddle client example.
Then I'am running go run main.go command in the /go/src/github.com/pions/webrtc/examples/data-channels folder on my server to launch data-channel.
After that I copy Browser base64 Session Description from jsfiddle example and paste it into my terminal where data-channels go script is running and it generates Golang base64 Session Description code which I paste into jsfiddle example and then press Sart session button.
And it fails to establish connection :(
This is my jsfiddle example for client side:
And this is my server side go script:
What am I doing wrong?
Thanks for using pion-WebRTC (I am one of the developers!)
WebRTC uses a technology called ICE to allow peers to talk to each other. Two peers exchange IP addresses via the SDP (the text you pasted) then they attempt to communicate by sending small UDP packets between each other. Once two IP addresses successfully communicate via ICE the rest of the WebRTC steps can continue. For you this process is failing. I don't know how/why though. Firewalls, VPNs etc... all can cause problems.
You will have to debug and check different scenarios. I would try running the examples on your local PC. If that works then maybe try between a different server. A good tool to help here also is tcpdump that can show if UDP packets are arriving. I usually use tcpdump -i any udp and inbound
We also recently added IPv6 support, so might be worth trying from master and see if that helps at all! Hopefully this helps, but if you are still having issues feel free to ask more questions. We are also all available via our Slack Channel you can sign up here here and would be more then happy to chat!
I met similar problem, and I solved by
echo $BROWSER_SDP | ./main
BROWSER_SDP is the session description in your browser, main is the exe by go build main.go(you can rename exe by mv). This can make sure transfer SDP to the server, which is really important.
The detail

what is the meaning of FTP attributes in Filewatcher Property file?

The Properties file of a file watcher contains many attributes. I was not able to find the use of certain attributes. The attributes are
FTPModeBinary and
FTPConnectionPASV
these take true or false as its value.
Can anyone please help me to understand the use of these attributes?
"Binary" (as opposed to "text") transfers the file exactly as-is without doing any end-of-line conversions (like LF to CR/LF).
"Passive" means that the FTP server always opens a listening socket for the data connection and the client connects to it. (FTP uses a separate TCP channel for the actual data transfer.) Traditionally, FTP would have the sender open a connection to the receiver but this began breaking when people started residing behind NAT firewalls as there's no easy way to open a connection back to the client in that case. Without passive, it's actually possible to instruct two FTP servers to transfer a file between themselves without ever passing through the client.

Open Socket fails if executable is on a network share

We have the problem that we are not able to open a socket, if the executable is on a network share:
errortext we get:
0.0.0.0:2220: In TcpipSocket::TcpipSocket: Invalid argument.
Some invalid argument was supplied (for example, specifying an invalid level
to the setsockopt function). In some instances, it also refers to the current
state of the socket-for instance, calling accept on a socket that is not
listening.
The real adress should be 127.0.0.1.
the program works fine if the exe lies on my local HDD
I'm suspecting "security" related reason, Like MS doesn't allow opening sockets from network shares
or something similar.
Somebody has some clue?
The program is written in C++ using Win32api
I found the solution in the MSDN Forum
If you are interested, details can be found here
social.msdn.microsoft.com

UWSGI specify socket location

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.

Resources