isignisign February 2016

UNIXSocket .connect() but don't have full path to socket

This is for a networks project I'm working on. It requires us to simulate a bridge. The sockets become the ports basically.

But I was told in order for a Unixsocket to work it needs the full path to the socket and I don't know what the full path is.

Is there anyway to get around this?

  s = UNIXSocket.new(SOCK_SEQPACKET)
  s.connect(padder(lan_one[i]))

The part thats going wrong is padder(lan_one[i]). Padder basically pads a "port" until its 108 characters long. Anyways because the "port" is made up it doesn't actually exist anywhere. Therefore I can't path to it.

Answers


John Bollinger February 2016

I don't know what the full path is.

You specify the path as a constructor argument. In other words, the path is what you say it is. Opening a socket this way creates an actual file on the file system if there isn't one already, and it fails (or should do) if it cannot create the file, such as because a file with the specified name already exists, or because a directory segment of the specified path does not exist.

The part thats going wrong is padder(lan_one[i]). Padder basically pads a "port" until its 108 characters long. Anyways because the "port" is made up it doesn't actually exist anywhere. Therefore I can't path to it.

It's unclear to me exactly how you should proceed. Unix-domain sockets don't have ports, per se, and certainly, you cannot connect to a socket that does not exist. You could simulate ports with paths, though. For example, you could use paths of this general form:

/base/dir/application/port

Do note that there is a system-specific limit on how long the names of Unix-domain sockets can be.

Post Status

Asked in February 2016
Viewed 1,926 times
Voted 13
Answered 1 times

Search




Leave an answer