|
-
July 8th, 2002, 08:35 PM
#1
Is Send() in SOcket class thread safe?
I would like to know if the Send() method in Socket class thread safe. THat mean, if two different objects happen to call mySocket.Send(..) on the same socket at the same time, will there be any problem in that?
I've read that in TCPClient, the GetStream class can be locked:
lock (myClient.getStream)
but how about in the Socket class for the Send() method?
-
July 9th, 2002, 08:04 PM
#2
According to the documentation, here is what is said about System.Net.Sockets.Socket:
Thread Safety
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
-
July 9th, 2002, 11:43 PM
#3
i read that too, but did not understand. public static members means wut? Instance members is created in this way rite:
public Socket mysock;
Is it? then how bout public static members? do i just put a static keyword in it it?
-
July 10th, 2002, 06:00 AM
#4
You'd used the static modifer. For example:
Code:
public static Socket mySock;
You could also synchornize any functions which use it to make sure they do collide.
-
July 10th, 2002, 07:04 AM
#5
Originally posted by CPCericola
You'd used the static modifer. For example:
Code:
public static Socket mySock;
You could also synchornize any functions which use it to make sure they do collide.
This would not make the Socket thread safe. The quote says that any public static members are thread safe. Simply making the Socket static doesn't have any effect on its members.
And I'm guessing that Send() is not a Thread safe operation on Sockets. If it was I would imagine they would say something about it.
Jared
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|