Hi,
I am facing 2 problems in Linux 2.2.16-22:
[1] In the server program (tmgr_main1.c) attached herewith, i am waiting on
events on the select system call on 3 sockets.
First I run the server program and its 3 client programs. If do a sendto in
this program just before waiting for select or do a sendto in response to read
events received by select, the message sent goes to the respective client and
the programs work perfectly fine.
However If i run only the server and do not run the client programs, then the
sendto done in the server program sends a message/event to the server itself (
which is waiting on events on that sockfd also) .
When i tried the above thing on SunOS 5.5.1 it worked perfectly fine!
(See attached file: server.c)
The output of this program is as follows:
[npunmia@msatpd1 tm1]$ ./a.out
In Test Manager main function !
Signal Handler installed!
Message sent to MRS!
Waiting on select system call....
Data received from MRS!
Error in receive!
Servicing a MRS request!
Message received =
--0__=dltXQeFTnMKfOnD683iUft1yk6wfySHrvedcK0UqZ34EMTK13oO3A0p5
Content-type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-transfer-encoding: quoted-printable
=80?c
Waiting on select system call....
Shutting down the test manager!
[npunmia@msatpd1 tm1]$
[2] The second problem occurs when i do a sendto 2 or more times in th=
is server
program. This time also I run only the server and do not run the
destination/clients programs. The point to note here is that i get a Co=
nnection
Refused error every second time i do a sendto! The first time the mess=
age is
sent correctly to the client , the second time i get Connection Refused=
error ,
third time the message is sent correctly to the client, and so on.
(I have commented the second sendto before select . To try problem no.=
2 you
can remove the comments and run it)
a) Why am i not getting a connection refused error consistently ev=
ery time
i do a sendto?
b) Why at all am i getting a connection refused error in UDP in t=
he first
place??
c) When i try the above thing on SunOS, the message is sent from t=
he server
correctly every time, even though the client processes are not alive an=
d i do
not get any error!!!
The output on running the above program(remove the comments from the s=
econd
sendto before select) is as follows:
[npunmia@msatpd1 tm1]$ ./a.out
In Test Manager main function !
Signal Handler installed!
Message sent to MRS!
Error in send to MRS
Error: Connection refused
Waiting on select system call....
Shutting down the test manager!
[npunmia@msatpd1 tm1]$
Regards,
Niraj Punmia,
Software Engineer,
Hughes Software Systems,
Plot 31, Sector 18,
Gurgaon- 122 015,
Haryana, India.
Off: 0124-6346666. Extn 2350.
=
--0__=dltXQeFTnMKfOnD683iUft1yk6wfySHrvedcK0UqZ34EMTK13oO3A0p5
Content-type: application/octet-stream;
name="server.c"
Content-Disposition: attachment; filename="server.c"
Content-transfer-encoding: base64
I2luY2x1ZGU8c3RkaW8uaD4NCiNpbmNsdWRlPHN5cy90eXBlcy5oPg0KI2luY2x1ZGU8c3lzL3Nv
Y2tldC5oPg0KI2luY2x1ZGU8bmV0aW5ldC9pbi5oPg0KI2luY2x1ZGU8YXJwYS9pbmV0Lmg+DQoj
aW5jbHVkZTxzaWduYWwuaD4NCiNpbmNsdWRlPHN5cy9wYXJhbS5oPg0KI2luY2x1ZGU8c3lzL3Rp
bWUuaD4NCg0KDQojZGVmaW5lIFRNX0dVSV9QT1JUIDYwMDAwICAvLyBpbiBUTSBmb3IgR1VJDQoj
ZGVmaW5lIFRNX01SU19QT1JUIDYwMDAxICAvLyBpbiBUTSBmb3IgTVJTDQojZGVmaW5lIFRNX01Q
X1BPUlQgNjAwMDINCg0KI2RlZmluZSBHVUlfVE1fUE9SVCA1MDAwMCAvLyBpbiBHVUkgZm9yIFRN
DQojZGVmaW5lIE1SU19UTV9QT1JUIDUwMDAxIC8vIGluIE1SUyBmb3IgVE0NCiNkZWZpbmUgTVBf
VE1fUE9SVCA1MDAwMg0KDQovLyNkZWZpbmUgVE1fSE9TVF9BRERSICIxMzkuODUuMjQzLjkwIg0K
DQppbnQgZ3VpU29ja0ZkLCBtcnNTb2NrRmQsIG1wU29ja0ZkOw0KDQp2b2lkIHRlcm1pbmF0ZVRt
Z3IoKQ0Kew0KCXByaW50ZigiU2h1dHRpbmcgZG93biB0aGUgdGVzdCBtYW5hZ2VyIVxuXHQiKTsN
CgljbG9zZShndWlTb2NrRmQpOw0KCWNsb3NlKG1yc1NvY2tGZCk7DQoJY2xvc2UobXBTb2NrRmQp
Ow0KCWV4aXQoMCk7DQp9IA0Kdm9pZCB0aW1lckhhbmRsZXIoKQ0Kew0KICAgICAgICBwcmludGYo
I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VjZWl2ZSFcblx0Iik7DQoJCX0NCgkJcHJpbnRmKCJTZXJ2aWNpbmcgYSBN
UCByZXF1ZXN0IVxuXHQiKTsNCgkJcHJpbnRmKCJNZXNzYWdlIHJlY2VpdmVkID0gJXNcblx0Iixt
ZXNnKTsNCgkJfQkNCgl9CQ0KCXJldHVybiAwOwkJIA0KfSANCgkgDQo=
--0__=dltXQeFTnMKfOnD683iUft1yk6wfySHrvedcK0UqZ34EMTK13oO3A0p5--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/