Click to See Complete Forum and Search --> : Multithreading Problems in Simple C language.


shivakumarthota
December 18th, 2002, 02:56 AM
I am writing a program which will connect to a remote server, by accepting user name and pwd. This program allows multi-user login also.

If there are multiple users logged in then each of them will receive a message from the remote server.

For this reason I have created a seperate port and a thread for each user. Inside the thread the program will listen on a particular port. The same is with other threads. Now when the data has come for a particular user the aprropriate thread is not getting activated resulting in data loss.

I have tried synchronizing but am not very clear on that concept.

Can you help me resolve this problem.

Regards,
Shivakumar Thota

mikledet
December 18th, 2002, 03:43 AM
shivakumarthota, (long name! :) )

I am not clear on exactly what your problem is - what I mean is - where do you need the help?
As far as the problem it slef i.e
Now when the data has come for a particular user the aprropriate thread is not getting activated
This can be many things - you will need to give more information about how and what you are trying to implement.
May be one thread (user) is blocking all the others who try to listen on the port?
Are you sure data realy get through? (just for example)

About synchronization, I am not clear what do you mean eather:
In the thread sense - synchronization is mainly to make sure, threads access shared data in a "safe" way - so synchronization here is ment between the threads them selves - however I got the feeling you might refer to synchronization here - as in between server and clients... I am not big on this subject - but i would guess thats a whole different ball game... (even if principals might be similar)

All the best

Dani

anujseth
December 19th, 2002, 03:34 PM
The problem could lie in the mechanism you are using for reading data from the socket.

Check whether you have a blocking socket, non-blocking socket. Whether you have specified the number of bytes that must be read, etc.

Infact, you should check out some sample TCP/IP client-server code. That might be useful in understanding what is wrong.

shivakumarthota
December 28th, 2002, 10:28 PM
Thank you very much mikledet and anujseth.
The probelm was real simple. And I was thinking it was a problem of threads synchromization. There was a simple buffer varible problem. And I found the solution.

Once again, Thank you very much both of you.

Regards,
Shivakumar Thota.