473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No connection could be made because the target machine actively refused it

28 New Member
On the Client Side, I programmed on Socket, when try to make connect Server and Client on the internet (WAN). I met 2 exception

1) No connection could be made because the target machine actively refused it
2)A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
public void Connect(string Host,int port){
try
{
create(this,null);
IPHostEntry he = Dns.Resolve(Host);
IPEndPoint ep = new IPEndPoint(he.AddressList[0], port);

if(m_BlockingMode)
{
m_Socket.Connect(ep);
return;
}
m_Socket.BeginConnect(ep,new AsyncCallback (OnSendEvents),"connect");
RecieveEventArgs rv = new RecieveEventArgs();
rv.m_DataLength = 255;
m_Socket.BeginReceive(rv.m_bytesArray,0,255,Socket Flags.None,new AsyncCallback(OnSendEvents),rv);
}
catch(SocketException ex)
{
MessageBox.Show(ex.Message);
}
}

and I met bug OnSendEvents
void OnSendEvents(IAsyncResult ar)
{
string s = ar.AsyncState.ToString();
switch(s)
{
case "connect":
connect(this,null);
if(ar.IsCompleted)
m_Socket.EndConnect(ar);
break;
case "send":
if(ar.IsCompleted)
m_Socket.EndSend(ar);
send(this,null);
break;
default :
RecieveEventArgs e = (RecieveEventArgs) ar.AsyncState;
e.m_ar = ar;
recieve(this,e);
break;
}
}

Can you help me.
Thu
Thanks
[email removed - against site rules]
Oct 25 '07 #1
2 8287
epots9
1,351 Recognized Expert Top Contributor
can you ping the other computer?
are you behind a firewall?
Oct 26 '07 #2
thupham
28 New Member
Yes, now I make connection at LAN succeed. But when I try to do in WAN, 2 computer can't connect, I just set IP public for server then NAT (in coming + out coming ). In the Client, I have more Clients, then I want to used IP Private. With Router ADSL of Client I NAT incoming, and I also stop firewall, but they still can't connect. they appear 2 bugs like before.
Have you ever programmed socket in WAN?
Can you help me.
Thanks for reply for me
Thu
Oct 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4788
by: Data | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
5
6274
by: Data | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
0
2229
by: gaurav tyagi | last post by:
i am trying to downlosd frles from a local ftp server in my network . here i am able to connect to server but to get file list from server i send "PASV" command it retuns some value which is not...
8
30792
by: hufaunder | last post by:
I have a website that consumes a webservice. Both of them are in the Default Website folder. I can execute the service without any problem when I go to the test page http://localhost/Service.asmx....
5
7688
by: OJ | last post by:
Hi, I am at a loss here, I have a c# asp.net website which connects to a remote SQL Server 2000 db via a connection string. If I set the website up in the filesystem and use the inbuilt cassini...
1
12529
by: Vikram S | last post by:
Hi All, I have an ASP.NET 2.0 web application on a web server and a separate machine for SQL Server 2000 Database. I am using a Connectionstring based on Sql Authentication to connect to the...
1
1315
by: urvika | last post by:
I have an ASP.NET 2.0 web application on a web server and a separate machine for SQL Server 2000 Database. I am using a Connectionstring based on Sql Authentication to connect to the the SQL 2000...
0
3202
by: Homer | last post by:
Hi, I got "InnerException: Unable to connect to remote server"..."No connection could be made because the target machine actively refused it" when I attempted to send an email through my...
0
1326
by: =?Utf-8?B?Sm9uIEphY29icw==?= | last post by:
I have a TCPListener in a Service. Works fine. But if I stop it and manually restart it, I get No connection could be made because the target machine actively refused it. in my app with the...
3
3732
by: Adhal | last post by:
Hi, I am using remoting to pass in parameters from new launches of an application. So basically I have only one instance of the application and I am using remoting to pass the parameters. ...
0
7216
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
7303
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
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5613
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,...
1
5028
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...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.