Re: Sockets and PTYs

Frank Gießler <giessler-rET10f8tM1VVKN/[email protected]> Wed, 28 Apr 2004 12:25:54 +0200
Newsgroups gmane.comp.ide.emx.devel
Message-ID <[email protected]>
Frank Gie=DFler wrote:
> I'm not so sure. If I don't call socket(), the second PTY will always b=
e=20
> opened. If I use DosOpen() instead of open(), the second PTY will also=20
> be opened, but now _imphandle() will fail (I hope _imphandle() can be=20
> used on a PTY). This socket() call seems to confuse the internal=20
> filehandle management of EMX. But I don't see how, yet.

Some more investigation on this. I built an emx.dll with some "debug"=20
information. The output should be self-explaining.

Here is what I get with the *old* TCP/IP version:

E:\x11_latest\xf86sup\example>socketpty.exe
socketpty: opening /dev/ptms$
reloc_handle: called for 3
reloc_handle: 3 is not a socket
socketpty: opening \dev\ptyp0
reloc_handle: called for 5
reloc_handle: 5 is not a socket
Successfully opened \dev\ptyp0, handle =3D5
socketpty: creating a socket
tcpip_new_handle: called for socket 16
tcpip_new_handle: i =3D 6
tcpip_new_handle: set flags 0x00001200
tcpip_new_handle: sock_proc_count[16] =3D 1
Socket created, handle =3D 6
socketpty: DosOpening \dev\ptyp1
Successfully opened \dev\ptyp1, handle =3D7
socketpty: _importing 7
reloc_handle: called for 7
reloc_handle: 7 is not a socket
_imphandle() successful, handle =3D7

And this I get with the new version:

E:\x11_latest\xf86sup\example>socketpty.exe
socketpty: opening /dev/ptms$
reloc_handle: called for 3
reloc_handle: 3 is not a socket
socketpty: opening \dev\ptyp0
reloc_handle: called for 5
reloc_handle: 5 is not a socket
Successfully opened \dev\ptyp0, handle =3D5
socketpty: creating a socket
tcpip_new_handle: called for socket 16
tcpip_new_handle: i =3D 6
tcpip_new_handle: set flags 0x00001200
tcpip_new_handle: sock_proc_count[16] =3D 1
Socket created, handle =3D 6
socketpty: DosOpening \dev\ptyp1
Successfully opened \dev\ptyp1, handle =3D6
socketpty: _importing 6
reloc_handle: called for 6
reloc_handle: I think handle 6 is a socket!!!
_imphandle failed, errno =3D 5 (I/O error)

Looks like the handle for the second PTY is the same as the socket=20
number, so EMX thinks it's a socket and takes the wrong measure. Can=20
anybody tell me who is responsible for filehandles and how they are=20
supposed to co-operate with sockets?

Thanks,
Frank.

--=20
  Frank Giessler
  Klinikum der Universitaet Jena               Tel.: +49-3641-9 32 57 80
  Biomagnetisches Zentrum                      Fax : +49-3641-9 32 57 72