Im trying to debug a problem related to IPCSockets and just found that, on Windows, I cant see the socket file created from my IPCSocket instance.
Neither with Windows Explorer or the command line I cant list the file.
Is that normal?
Yes.
Thanks Joe, can I ask why?
On Mac I can see the file, though its a special one, but in *NIX everything is a file…
[quote=59178:@Massimo Valle]Thanks Joe, can I ask why?
On Mac I can see the file, though its a special one, but in *NIX everything is a file…[/quote]
Because on Windows its not a file
Plain and simple
It’s not how Windows handles this sort of thing
Norman, can you give some details on how it is implemented on Windows ?
I am looking for a way to hook other languages into Xojo’s IPC communication under Windows …
Thank you very much,
Harald
[quote=201120:@Harald Schneider]Norman, can you give some details on how it is implemented on Windows ?
I am looking for a way to hook other languages into Xojo’s IPC communication under Windows …
Thank you very much,
Harald[/quote]
For a non-Xojo app you’ll need joes code from https://forum.xojo.com/20033-ipcsocket-protocol-info
Thanks - but this link only shows “Page not found” :-/
This is the best informative thread about IPCSocket, written by Aaron Ballman (formerly RealStudio developer).
http://forums.realsoftware.com/viewtopic.php?f=2&t=2735
Actually the only thing unclear to me about IPCSocket is how a TCP port is computed starting from the IPCSocket.Path on Windows.
This would really help me solving a lot of problems…
Thanks Massimo I also googled this one:
https://forum.xojo.com/2839-xojo-ipcsockets-not-working/12
with this nice summary:
I installed a socket sniffer on Windows and I can see port 5079, wich is calculated from the path of the IPCSocket example coming with Xojo.
@Norman: Any hints how this is calculated ?
Hmmm … the next time I start the app it uses port 5108 … maybe it probes previously used ports with each startup …
Ah its posted in Xojo Pro
[quote=201148:@Massimo Valle]This is the best informative thread about IPCSocket, written by Aaron Ballman (formerly RealStudio developer).
http://forums.realsoftware.com/viewtopic.php?f=2&t=2735
Actually the only thing unclear to me about IPCSocket is how a TCP port is computed starting from the IPCSocket.Path on Windows.
This would really help me solving a lot of problems…[/quote]
Joes post says
[quote=168010:@Joe Ranieri]On Windows, Xojo IPCSockets are just a TCP socket bound to localhost. The port it listens on is determined by the ‘path’ of the IPCSocket. Here is that algorithm:
[code]Function PipeNameToPortNumber(name As String) As UInt16
// We’re given a pipe name and we want to convert it into a unique port number
// that’s higher than 1024.
Dim length As Integer = LenB(name)
Dim hash As Integer = 0
For i As Integer = 1 To length
Dim ch As Integer = Asc(MidB(name, i, 1))
If ch >= 97 And ch <= 122 Then
ch = ch - 32
End If
hash = (hash * 32) - hash + ch
Next
// Constrain the results to 65535 - 1025
hash = hash Mod 64510
// And make sure it’s > 1024
return hash + 1025
End Function[/code]
Or in its original C++ form:
[code]static unsigned short PipeNameToPortNumber( string name )
{
// We’re given a pipe name and we want to convert it into
// a unique port number that’s higher than 1024.
int length = name.size();
int hash = 0;
for (int i = 0; i < length; i++) {
char ch = name[i];
if (ch >= ‘a’ and ch <= ‘z’) {
ch -= 32;
}
hash = (hash << 5) - hash + ch;
}
// Constrain the results to 65535 - 1025
hash %= 64510;
// And make sure it's > 1024
return hash + 1025;
}[/code][/quote]
Thank you so much, Norman !
I’d just like to point out that this is subject to change in the future. I would love to find the time to change IPCSocket on Windows to use named pipes at some point.
Yes, this would make cross-platform code, like connecting other languages to ipcsockets, much easier.