473,401 Members | 2,139 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,401 software developers and data experts.

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

28
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 8284
epots9
1,351 Expert 1GB
can you ping the other computer?
are you behind a firewall?
Oct 26 '07 #2
thupham
28
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.