Tuesday, May 7, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 23766  / 1 Year ago, wed, march 22, 2023, 1:33:32

I want to create a new socket file in /dev. Does the way to get it is adding a new rule to udev?


More From » application-development

 Answers
3

  • The usual way to create a Unix domain or TCP socket is programatically, via the mknod or socket system calls. The mknod command will not allow you to create a socket.



From the command line, use the socket package




  • If you wish to create a Unix/TCP socket from the command-line, try the socket command from the socket package (install it first). Summarizing its man page description:




    Socket creates an Internet domain TCP or a UNIX domain stream socket and connects it to stdin and stdout.





Examples of socket usage (from man page)




  1. socket -v coma.cs.tu-berlin.de nntp



    connects to the nntp port (port 119) of coma.cs.tu-berlin.de
    (130.149.28.10).


  2. socket -sl 3425



    creates a server socket on port 3425 on the local host and waits for a
    connection. After a connection has been closed, a new connection is
    accepted.


  3. socket -wslqvp "echo Socket! " 1938



    creates a server socket on port 1938 on the local host and waits for a
    connection. When a connection is accepted, the string "Socket!" is
    written to the socket. No data is read from the socket and written to
    the finger program. The connection is closed when an end-of-file
    condition at the standard output of the program occurs. Then a new
    connection is accepted.



[#37585] Friday, March 24, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
vigorousom

Total Points: 394
Total Questions: 96
Total Answers: 110

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;