XtAddInput not working with socket

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

3 posts / 0 new
Last post
XtAddInput not working with socket

Submitted by Millenniumman on Mon, 06/25/2007 - 22:01.

Should XtAddInput normally be triggered by data that is already written (write()) on a socket when XtAddInput is run, but has not yet been read by anything?

If not, is there any way to do this?
If so, is there anything that would prevent this from happening?

I am trying to get it to do this, but it is not being triggered. It is triggered by the same data if XtAddInput is run beforehand, so the handler is registered before any data is written, but this is not always possible.

This is at the server of the socket, XtAddInput is set to watch the result of an accept() function. A different handler function, set by an earlier XtAddInput call, has already been triggered by a connect(). It calls the XtAddInput in question.

I am aware that the XtAdd* functions are depreciated, but that doesn't seem to be the problem here. Does it?

Mon, 06/25/2007 - 23:08#1

Mon, 06/25/2007 - 23:08#1

Millenniumman

XtAddInput not working with socket

I can see that what I wrote isn't really clear. Here are how the client and server are supposed to work:

Server:
SocketCreator - creates pipe, sets ConnectHandler to watch it with XtAddInput
ConnectHandler - is triggered when client connect()s to socket. ConnectHandler accept()s, and sets InitialDataHandler to watch it with XtAddInput
InitialDataHandler - is triggered when client write()s data to socket. Get's initial data about client and sets MainClienthandler to watch for anything else.
MainClienthandler - watches for any other data

Client:
SocketConnector - connect()s to socket (it gets the filename from environment variables)
InitialDataWriter - write()s initial data to socket
OtherClientFunctions - ask ServerFunc for data, select()s until socket is available

What is happening is that InitialDataWriter runs before ConnectHandler. ConnectHandler runs properly and sets InitialDataHandler as the input handler function, but InitialDataHandler never responds to the data that has already been written to the pipe by InitialDataWriter. If I use a sleep(30) to prevent InitialDataWriter from write()ing the data before ConnectHandler runs, InitialDataHandler responds to the written data and everything is okay. It just won't respond to already written data.

I think this may be something wrong with the socket, but I am unsure what. Does anyone know?

Or is it an issue with XtAddInput?

 

 

Tue, 08/14/2007 - 10:18#2

Yuriy Syrota

XtAddInput not working with socket

Millenniumman,

It is hard to gues what is the reason of the issue. Why don't you just prepare simple test case demonstrating issue and post here?