简体   繁体   中英

Can javascript socket io listen unix sock?

Expected behavior

  • Server : unix://IP_ADDRESS/path/to/setup.sock
  • Client : javascript (cannot using node.js only can use socket.io or web socket)
  • Communicate server <-> client

Actual behavior

  • Web socket cannot listen unix://
  • I dont know how to listen or send message using socket.io

I'm so noob. Can anyone help me?

Unfortunately, web sockets won't be able to connect to AF_UNIX sockets, due to the nature of web sockets.

Looking at the RFC for web sockets they are

Conceptually, WebSocket is really just a layer on top of TCP [...]

Also, the web socket connection is initiated via HTTP. This means web sockets, as of now, are bound to TCP and I'm not sure what use case constrains you to Web Sockets instead of using regular local AF_UNIX sockets to access a local unix socket.

You should probably look into using the server to proxy between the unix socket and a web socket, if you have to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM