473,395 Members | 1,999 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,395 software developers and data experts.

Sockets Problem when converting winsock vb6 to c#

Hi. I have an application that uses sockets, as per below:

m_clientSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp );
int iPortNo =8000;
IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);
m_clientSocket.Connect ( ipEnd );

It works fine, however when I close my application, the application does not
receive any more data via the sockets and the application that sends it the
data (a windows service) must be restarted. I have a similar application that
uses the winsock control with vb6, and this works perfectly and the windows
service never needs to be restarted with the vb6 app, only the .net one.

I have tried different methods to close the socket when i shutdown my .net
app, such as :

m_clientSocket.Shutdown(System.Net.Sockets.SocketS hutdown.Both);
m_clientSocket.EndReceive(s);
m_clientSocket.Close();
m_clientSocket = null;

But it makes no difference, the windows service always needs to be
restarted. Does anyone have any ideas at all?

Thank you!

Dave
May 31 '06 #1
2 2260
Ok Dave, you said "when I close my application" so I assume you have an
interface. Perhaps you can separate your interface with your windows
service. So you can start and stop them separately.

chanmm

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
Hi. I have an application that uses sockets, as per below:

m_clientSocket = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp );
int iPortNo =8000;
IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);
m_clientSocket.Connect ( ipEnd );

It works fine, however when I close my application, the application does
not
receive any more data via the sockets and the application that sends it
the
data (a windows service) must be restarted. I have a similar application
that
uses the winsock control with vb6, and this works perfectly and the
windows
service never needs to be restarted with the vb6 app, only the .net one.

I have tried different methods to close the socket when i shutdown my .net
app, such as :

m_clientSocket.Shutdown(System.Net.Sockets.SocketS hutdown.Both);
m_clientSocket.EndReceive(s);
m_clientSocket.Close();
m_clientSocket = null;

But it makes no difference, the windows service always needs to be
restarted. Does anyone have any ideas at all?

Thank you!

Dave

Jun 1 '06 #2

i chanmm,

thanks for the post, i did a bit more tinkering.

I realised that when i ran my application from VS2003 i was not running the
socket shutdown code when i stopped the application. What a plum!

Cheers,
Dave

"chanmm" wrote:
Ok Dave, you said "when I close my application" so I assume you have an
interface. Perhaps you can separate your interface with your windows
service. So you can start and stop them separately.

chanmm

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:1A**********************************@microsof t.com...
Hi. I have an application that uses sockets, as per below:

m_clientSocket = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp );
int iPortNo =8000;
IPEndPoint ipEnd = new IPEndPoint (ip,iPortNo);
m_clientSocket.Connect ( ipEnd );

It works fine, however when I close my application, the application does
not
receive any more data via the sockets and the application that sends it
the
data (a windows service) must be restarted. I have a similar application
that
uses the winsock control with vb6, and this works perfectly and the
windows
service never needs to be restarted with the vb6 app, only the .net one.

I have tried different methods to close the socket when i shutdown my .net
app, such as :

m_clientSocket.Shutdown(System.Net.Sockets.SocketS hutdown.Both);
m_clientSocket.EndReceive(s);
m_clientSocket.Close();
m_clientSocket = null;

But it makes no difference, the windows service always needs to be
restarted. Does anyone have any ideas at all?

Thank you!

Dave


Jun 1 '06 #3

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

Similar topics

1
by: Dmitry Akselrod | last post by:
Hello everyone, I have a vb.net application that wraps the TCPListener object in a class. The server connects to the local interface and establishes itself on port 9900. It then polls for...
1
by: Ben | last post by:
I've written a fair amount of sockets code using the Winsock2 API, but I am having some trouble converting to the .Net Sockets API, specifically asynchronous sockets. What I have is a form that is...
4
by: Garam | last post by:
I need to write a substantial amount of network code in C. The thing is, it has to be able to run on both Unix and Windows. Rather than writing separate code for each, I was looking for something...
2
by: Nadav | last post by:
Hi, I am about to write a performance critical application and I wonder what is the best way to implement it... Should I use the standart Win32 winsock DLL or should I rather use the new managed...
0
by: Björn Pedersen | last post by:
I'm having a tough time getting System.Net.Sockets to work with a server that's based around Winsock 6.0. For many reasons I can't write a new server because the server handles a number of client...
15
by: mrpolitics | last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd) and everything was fine untill yesterday when the server crashed. So I did a cold restart and staretd the server back up...
2
by: b.m. | last post by:
Hi, I'm a beginner to VB.NET ... I ve been trying to learn .net System.Net.Sockets but i cant seem to figure out a few things... Being that I am an ex-VB6 developer, I am pretty used to...
4
by: Greg Young | last post by:
Ok so I think everyone can agree that creating buffers on the fly in an async socket server is bad ... there is alot of literature available on the problems this will cause with the heap. I am...
0
by: =?Utf-8?B?TWFydGluVGVlZnk=?= | last post by:
Hi, I've read a lot about the use of system sockets in Vb.net instead of winsock fine but how do i get a vb.net service running on a 2003 server to send a message to a desktop vb6 exe that can...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.