Sockets and PTYs
Frank Gießler <giessler-rET10f8tM1VVKN/[email protected]> Tue, 27 Apr 2004 15:51:07 +0200
| Newsgroups | gmane.comp.ide.emx.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------040803090202010908030501
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
I hope there is someone present on this list. It looks like newer TCP/IP
versions (beginning with around 4.2) at least partly break EMX support
for xf86sup. After a socket is created, PTYs can't be opened any more.
The attached code illustrates this. I first opens a PTY, then creates a
socket, and then tries to open another PTY, which fails. I don't really
know how the TCP/IP version can be causing this. The output of the
program is:
[E:\x11_latest\xf86sup\example]socketpty
Successfully opened \dev\ptyp0, handle =5
Socket created, handle = 6
Cannot open pty \dev\ptyp1, errno = 5 (I/O error)
Any ideas, anybody?
Kind regards,
Frank.
--
Frank Giessler
Klinikum der Universitaet Jena Tel.: +49-3641-9 32 57 80
Biomagnetisches Zentrum Fax : +49-3641-9 32 57 72
--------------040803090202010908030501
Content-Type: image/x-xbitmap;
name="socketpty.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="socketpty.c"
#define INCL_DOS
#define INCL_DOSPROCESS
#include <os2.h>
#include "../api/ptyos2.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
main()
{
int i;
int fdptms;
int fd[2];
int errcode = 1;
APIRET rc;
ULONG in = 1, len;
char name[14];
int Socket = -1;
fd[0] = fd[1] = -1;
/* Open a PTY */
if ((fdptms=open("/dev/ptms$",0)) <0) {
errcode = errno;
fprintf(stderr,"Cannot open /dev/ptms$, errno = %d (%s)\n",
errcode,strerror(errcode));
goto cleanup;
}
rc = DosDevIOCtl(fdptms, XFREE86_PTY, PTMS_GETPTY,
&in, sizeof(ULONG), &len,
&name, sizeof(name), &len);
if (rc) {
fprintf(stderr,"Error PTMS_GETPTY: rc = %d\n",rc);
goto cleanup;
}
fd[0] = open(name,0);
if (fd[0]<0) {
errcode = errno;
fprintf(stderr,"Cannot open pty %s, errno = %d (%s)\n",
name,errcode,strerror(errcode));
} else
printf("Successfully opened %s, handle =%d\n",name,fd[0]);
/* Let's create a socket */
if ((Socket = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
errcode = errno;
fprintf(stderr,"Failed to create socket, errno = %d (%s)\n",
errcode, strerror(errcode));
goto cleanup;
}
fprintf(stderr,"Socket created, handle = %d\n",Socket);
/* Open another PTY */
rc = DosDevIOCtl(fdptms, XFREE86_PTY, PTMS_GETPTY,
&in, sizeof(ULONG), &len,
&name, sizeof(name), &len);
if (rc) {
fprintf(stderr,"Error PTMS_GETPTY: rc = %d\n",rc);
goto cleanup;
}
fd[1] = open(name,0);
if (fd[1]<0) {
errcode = errno;
fprintf(stderr,"Cannot open pty %s, errno = %d (%s)\n",
name,errcode,strerror(errcode));
} else
printf("Successfully opened %s, handle =%d\n",name,fd[1]);
close (fdptms);
/* cleanup all */
cleanup:
for (i=0; i<2; i++)
if (fd[i]>=0) close(fd[i]);
shutdown(Socket,2);
exit(errcode);
}
--------------040803090202010908030501--