C# Socket Error Code 10042
Contents |
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and socket error 10054 reference Dev centers Retired content Samples We’re sorry. The content you requested
What Is A Socket Error
has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums socket error 10053 users FAQ Search related threads Remove From My Forums Answered by: TcpListener getting 10042 error code Archived Forums # > .NET Framework Networking and Communication Question 0 Sign in to
Socket Error 10054 Connection Reset By Peer
vote When creating a TcpListener object I am getting error code 10042. Below is the code I am using. IPHostEntry localMachineInfo = Dns.GetHostEntry(Dns.GetHostName()); IPEndPoint localEP = new IPEndPoint(localMachineInfo.AddressList[0], System.Convert.ToInt32(tbPort.Text)); TcpListener listener = new TcpListener(localEP); listener.Start(); When debugging this code I notice that right after listener object is created I see error code 10042 (An unknown, invalid, or unsupported option or level was socket error 10049 specified in a getsockopt or setsockopt call). am I missing a configuration setup ? Thursday, February 08, 2007 5:52 PM Answers 0 Sign in to vote You are welcome , If you feel my replies helped you in your problem. Please mark as Answered. Best Regards, Rizwan aka RizwanSharp Friday, February 09, 2007 4:16 PM All replies 0 Sign in to vote The Socket Error Code 10042 says : Bad Protocol Option. In my point of view using TcpListener should not raise such type of exception because unlike the direct use of Socket you cannot specify wrong arguments in Constructor but TcpListener is well formed socket with right protocol selection. Your code also seem totally fine. I would only suggest you to see what IP is in AddressList[0], Is it a valid IP. Besides this you can also try: TcpListener listener = new Listener(IPAddress.Any, port); listner.Start(); Does this make a difference? Best Regards, Rizwan aka RizwanSharp Thursday, February 08, 2007 6:27 PM 0 Sign in to vote It did not make a difference. Actually I've just noticed that before creating the TcpListener o
4, 20042 0 0 0 Remembering numeric error codes is hard. Unless the error handling code is well documented, code reviews take longer and
Socket Error Codes Linux
maintenance is more difficult as you may need to
Socket Error 10061 Connection Refused
consult reference manuals, native code header files or online help frequently. Socket errors socket error 11001 are particularly hard for me to remember. To help myself out, I have collected Windows Sockets error codes into a couple of https://social.msdn.microsoft.com/Forums/en-US/7b97bf3f-88bb-44d0-96cb-a0639d3b3ef7/tcplistener-getting-10042-error-code?forum=netfxnetcom enums. The first enum, SocketErrorCodes uses friendly descriptions based on the following Microsoft Support article . For detailed descriptions of the error codes, please refer to this article or a Windows Sockets reference.
public enum SocketErrorCodes
{
InterruptedFunctionCall = 10004,
PermissionDenied = https://blogs.msdn.microsoft.com/davidklinems/2004/11/04/simpifying-socket-exception-handling/ 10013,
BadAddress = 10014,
InvalidArgument = 10022,
TooManyOpenFiles = 10024,
ResourceTemporarilyUnavailable = 10035,
OperationNowInProgress = 10036,
OperationAlreadyInProgress = 10037,
SocketOperationOnNonSocket = 10038,
DestinationAddressRequired = 10039,
MessgeTooLong = 10040,
WrongProtocolType = 10041,
BadProtocolOption = 10042,
ProtocolNotSupported = 10043,
SocketTypeNotSupported = 10044,
OperationNotSupported = 10045,
ProtocolFamilyNotSupported = 10046,
AddressFamilyNotSupported = 10047,
AddressInUse = 10048,
AddressNotAvailable = 10049,
NetworkIsDown = 10050,
NetworkIsUnreachable = 10051,
NetworkReset = 10052,
ConnectionAborted = 10053,
ConnectionResetByPeer = 10054,
NoBufferSpaceAvailable = 10055,
AlreadyConnected = 10056,
NotConnected = 10057,
CannotSendAfterShutdown = 10058,
ConnectionTimedOut = 10060,
ConnectionRefused = 10061,
HostIsDown = 10064,
HostUnreachable = 10065,
TooManyProcesses = 10067,
NetworkSubsystemIsUnavailable
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business http://stackoverflow.com/questions/8573607/using-different-protocols-in-same-application-using-same-socket Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Using Different protocols in same application using same socket up vote 0 down vote favorite Can I send and receive UDP datagrams on same socket error socket,I am using for TCP communication.There exist multimedia communication in my application for which I have to use UDP for communication.If i create a new socket it threw an exception for properties of LingerState and NoDelay.When I Assigns the Old Socket Instance to other Socket variable it doesn't Allow me to change the properties as most of the properties are read Only.I have to Send data in the TCP connected Area. *Code * Socket SendingSocket = socket error code new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint Endp = new IPEndPoint(IPAddress.Parse("192.168.3.233"), port); SendingSocket.Bind(Endp); while (SendingSocket.Connected) { string Message = "Testing Message Sending Over UDP"; ASCIIEncoding Encode = new ASCIIEncoding(); byte[] MessageBytes = Encode.GetBytes(Message); SendingSocket.SendTo(MessageBytes, 0, MessageBytes.Length, SocketFlags.None, Endp); }' c# sockets udp client-server share|improve this question edited Dec 21 '11 at 4:38 asked Dec 20 '11 at 9:53 Samie 4329 1 TCP and UDP work completely differently. TCP maintains a constant connection between client/server until it's closed/dropped. UDP doesn't. Any software that I've seen needing both have two sockets in use, one for TCP and the other for UDP. –GeoffM Dec 20 '11 at 10:19 I am Just asking that it is the requirement of the application.That I have communicate separably –Samie Dec 20 '11 at 11:10 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote Hard to tell from that code fragment but possibly you do not need the SendingSocket.Bind(Endp) since your SendingSocket.SendTo also includes the IP end point. Also try simply SendingSocket.SendTo(MessageBytes, Endp); share|improve this answer answered Dec 20 '11 at 22:01 GeoffM 73621123 add a comment| up vote 0 down vote No. You can not use the same socket for both TCP and UDP. A socket is bound to only one protocol. share|improve this answer answered Dec 20 '11 at 11:44 jgauffin 68.4k25149265