473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Socket Exception

We have a little server application that sends data down to a client application via a TCP/IP socket over port 30006. These
applications are both written in C#. They have been working on our site for a couple of years. Now, we are trying to use these
applications at another site and we get an exception on the following line:-

Socket oRequest = new Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);

The exception identifies itself as 10022 which is described as invalid argument.

My questions are

1) Is the Socket creation line an example of bad programming and we have been lucky to get away with it for 2 years?

1a) What is a better command to create a new Socket object to use over TCP/IP?

2) What are the circumstances in which the above line would fail? As far as we can see, the PCs have TCP/IP installed on them.
Internet explorer works for example.

Thanks for any help given.
--
Steve Walton

Feb 21 '07 #1
2 2681
Hi,

"Steve Walton" <No****@NoSpam.comwrote in message
news:d3********************************@4ax.com...
We have a little server application that sends data down to a client
application via a TCP/IP socket over port 30006. These
applications are both written in C#. They have been working on our site
for a couple of years. Now, we are trying to use these
applications at another site and we get an exception on the following
line:-

Socket oRequest = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);

The exception identifies itself as 10022 which is described as invalid
argument.

My questions are

1) Is the Socket creation line an example of bad programming and we have
been lucky to get away with it for 2 years?
If that constructor exist, then you could use it. personally I see nothing
wrong with it.
1a) What is a better command to create a new Socket object to use over
TCP/IP?
Personally I always tend to use TcpClient over socket. Regarding how to
create your code seems ok
2) What are the circumstances in which the above line would fail? As far
as we can see, the PCs have TCP/IP installed on them.
Internet explorer works for example.
Did you see if there were an InternalException ?
Feb 21 '07 #2
"Steve Walton" <No****@NoSpam.comwrote
[...]
Now, we are trying to use these
applications at another site and we get an exception on the following
line:-

Socket oRequest = new
Socket(AddressFamily.InterNetwork,SocketType.Strea m,ProtocolType.Tcp);

The exception identifies itself as 10022 which is described as invalid
argument.
I don't know what that error really means there. It's.... strange. Do you
have a full stack trace on the exception you can share?
>
My questions are

1) Is the Socket creation line an example of bad programming and
we have been lucky to get away with it for 2 years?
This is completly legit. We do it all over the place, on tens of thousands
of computers. No trouble.
1a) What is a better command to create a new
Socket object to use over TCP/IP?
It dependson your use case. I use the command you described above. There's
also TCPClient and Network stream.
>
2) What are the circumstances in which the above line would
fail? As far as we can see, the PCs have TCP/IP installed on them.
I'm not sure. Got a full exception you can provide?
--
Chris Mullins, MCSD.NET, MCPD:Enterprise, Microsoft C# MVP
http://www.coversant.com/blogs/cmullins
Feb 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Russell Warren | last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it a cross-process/system setting or does it stay local in the application in which it is called? I've been testing this and...
4
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
2
by: Nuno Magalhaes | last post by:
I've got a simple problem I guess. How do I know when a connection is terminated without losing any data? I do something like the code below, but sometimes between socket.Receive and socket.Send...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
3
by: Cheryl | last post by:
Hi. I am having a problem on handling asynchronous sockets in C#. I implemented a pair of client and server sockets. The connection is ok when first connected. However, when I turned off the...
2
by: manasap | last post by:
Hi all! I've written a server and a client application using asynchronous sockets.The client sends data packets for every 7 seconds.The server receives the packets. This process proceeds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.