.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

.NET Sockets and the firewall.

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :.NET Framework
 
I've written a fairly simple tool that opens a socket and waits for requests. Nothing fancy. When I build and run as a tool, my system pops up a dialog needing admin approval. Give it such and the apps runs along handling requests from the network. Great. When I build it as a service it isn't receiving requests. As a test I turned off the firewall. With the firewall off, it's working fine as a service. So the firewall is blocking my service. My question is, what do I need to do when building as a service that allows the port to be open? I've dug through .NET and don't see support for this. What little I've found Googling has all been fairly old (like 5+ years).  Anyone know the right solution?  


View Complete Post


More Related Resource Links

Test Run: WCF Service Testing with Sockets

  

There are many ways to test WCF services, but the socket-based approach is flexible and very useful for security and performance testing. We show you show you how to test a WCF service using a network socket based approach.

James McCaffrey

MSDN Magazine February 2010


Winsock: Get Closer to the Wire with High-Performance Sockets in .NET

  

The Win32 Windows Sockets library (Winsock) provides mechanisms to improve the performance of programs that use sockets, and the Microsoft .NET Framework provides a layer over Winsock so that managed applications can communicate over sockets. To use all these layers to write a truly high-performance socket-based application requires a little background information, as Daryn Kiely explains here.

Daryn Kiely

MSDN Magazine August 2005


Secure Sockets Layer: Protect Your E-Commerce Web Site with SSL and Digital Certificates

  

Security is one of the most important factors in the future growth of e-businesses. Making sure that communications remain secure between customers and the Web server is a critical issue. Secure Sockets Layer (SSL) is the standard that secure Web sites are built upon today. This article presents an overview of SSL-based Web security, explaining such fundamental concepts as digital certificates and their distribution, encryption, and the proper configuration of Microsoft Internet Information Services (IIS). Acquiring a certificate, installing it, and configuring IIS for SSL are outlined in a step-by-step process.

John Papa

MSDN Magazine April 2001


Windows Sockets 2.0: Write Scalable Winsock Apps Using Completion Ports

  

Writing a network-aware application isn't difficult, but writing one that is scalable can be challenging. Overlapped I/O using completion ports provides true scalability on Windows NT and Windows 2000. Completion ports and Windows Sockets 2.0 can be used to design applications that will scale to thousands of connections. The article begins with a discussion of the implementation of a scalable server, discusses handling low-resource, high-demand conditions, and addresses the most common problems with scalability.

Anthony Jones and Amol Deshpande

MSDN Magazine October 2000


Sending TelNet Sockets?

  

How can i send TelNet sockets through aspx.cs code?

like sending sockets through PuTTy...


is it possible?


An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll

  
Additional information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respondThis error occurs when i was executing a vc++.net program implementing ICMP....Error occurs when executing this statement... iRet=st->ReceiveFrom(RecvByte,RecvByte->Length,SocketFlags::None,&senderRemote);How to solve this problem????

Can I use TCP sockets within managed funcs, triggers and stored procedures?

  
I have seen nothing prohibiting this, but have not yet had time to write some test code. Does anyone know for sure if SQL Server 2008 prohibits or allows TCP sockets for communications, inside a C# SQL/CLR function or method? I guess it must because this is implict when creating data connections and so on, which are obvioulsy allowed. Thanks Cap'n  

Issues regarding sockets (stopping receiving packets).

  
Hello, I've created a server for my game, but for some unknown reason the server (most likely) stops receiving packets while the client still tries to send them. I've tried to use a couple examples from MSDN, but it still just stops receiving. This is what I think that happens: Client connects to server Server sends packets as response Client responds to those packets Server sends a lot of packets (one packet at a time) Client tries to send packet, but it kinda fails (it does send packets though!) Server waits (doesn't get any packet anymore) Client triggers timeout code on the server side and gets disconnected from the server Does anyone have an idea how and why this can happen? Here are the receive functions I use: BeginReceive (SocketInfo includes data such as amount of data to receive, state of packet (header or content) and the buffer) public void BeginReceive(SocketInfo socketInfo) { if (mDisconnected != 0) return; try { args = new SocketAsyncEventArgs(); args.Completed += (s, a) => EndReceive(a); args.UserToken = socketInfo; args.SetBuffer(socketInfo.DataBuffer, socketInfo.Index, socketInfo.DataBuffer.Length - socketInfo.Index); if (args != null) { try { if (!Socket.ReceiveAsync(args)) EndReceive(args); } catch (ObjectDisposedException) { Disconnect(); return; }

WCF communication blocked by firewall (or something)

  
So here's the deal... I have a web application with WCF services hosted in the web while the client is a WinForm app. Even though the web app listens on both port 80 and 443, some clients (PC clients) can't reach the services getting a TimeoutException.  In some cases I figured out the was a local antivirus (i guess with a firewall) called Nod32 wich was blocking the communication, I had to add my client "as a browser" and it sterted to work just fine. But in some other clients there are firewall preventing the communication. So, I have two questions. 1) Is there anything I can do in my client app to give the user better info about the problem? (The timeoutException does not say anything really). and... 2) What should I tell a Network Administrator that needs to be 'open' for the client to connect?   Let me know if anybody needs further info about config to answer these questions.   regards, Seba    http://sgomez.blogspot.com

Sockets in Windows Forms, Server Hanging

  
First off, I'm relatively new to C# but not programming.  I've written multiple connection apps in VB6 off and on for the last 8 years.  The problem with my server is that it hangs when ChatServer() is called and nothing appears in the rich text box.  I have no idea how to correct this or get it to start listening for connections, accept them, then retrieve data.  Pretty much learning as I go.  Here's the server so far: Any help would be greatly appreciated.   Edit:  I rewrote the server code using Winsock Control 6.0.  I know it's outdated but it's what I know and fairly well.  However, I noticed they did away with control array's!  What in the world?  Instead of setting a control's index property to 0, you now have to create references, objects, etc. etc.  SO much code for something so simple.  Anyway.  The problem now lies with the following code:   namespace Simple_Chat { public partial class frmServer : Form { int maxPlayers = 100; int index; public frmServer() { InitializeComponent(); } public void addToChat(string p, string fntcolor) { switch(fntcolor) { case "red": rtbMain.SelectionColor = Color.Red; rtbMain.SelectedText = p; break; case "blue": rtbMain.Selecti

C# Asynchronous Sockets Problem

  
Dear Programmers, I have some trouble in using Asynchronous Sockets in my application . My C# Window Application Working as Server and several clients to this Server and start data transmitting. Sometimes from a particular  Client i got continues Null Value Client exactly not sending but i m receiving and my application got hang and stop working , What is the problem can any one help me to resolve this problem .   Thanks  JainAmit      

Sockets in Windows Forms, Server Hanging

  
First off, I'm relatively new to C# but not programming.  I've written multiple connection apps in VB6 off and on for the last 8 years.  The problem with my server is that it hangs when ChatServer() is called and nothing appears in the rich text box.  I have no idea how to correct this or get it to start listening for connections, accept them, then retrieve data.  Pretty much learning as I go.  Here's the server so far: Any help would be greatly appreciated.   Edit:  I rewrote the server code using Winsock Control 6.0.  I know it's outdated but it's what I know and fairly well.  However, I noticed they did away with control array's!  What in the world?  Instead of setting a control's index property to 0, you now have to create references, objects, etc. etc.  SO much code for something so simple.  Anyway.  The problem now lies with the following code:   namespace Simple_Chat { public partial class frmServer : Form { int maxPlayers = 100; int index; public frmServer() { InitializeComponent(); } public void addToChat(string p, string fntcolor) { switch(fntcolor) { case "red": rtbMain.SelectionColor = Color.Red; rtbMain.SelectedText = p; break; case "blue": rtbMain.Selecti

Disable SharePoint Workspace alert on Windows 7 PC with Norton Firewall Provider.

  
My wife has a laptop with Windows 7 and Office 2010.  Recently she was playing with some settings on her PC and did something which now causes a "Microsoft SharePoint Workspace" alert to appear when she boots up the machine. She wants this message to go away.  I do not know how to do this, and searching for portions of the alert have lead nowhere.  Here is the exact message. SharePoint Workspace is unable to communicate through your firewall and will run with limited functionality.  To resolve this problem, enable SharePoint workspace as a Windows Firewall exception.  For assistance, contact your Windows administrator. To remedy this, here is what I attempted: Start > Control Panel > View by Small Icons > Windows Firewall This opens a dialog with the caption, "Help protect your computer with Windows Firewall".  Below that, there is an orange box with the notification, "These settings are being managed by vendor application NORTON FIREWALL PROVIDER." Of the half-dozen options that appear in the left navigation panel of that dialog, only 3 are enabled: control panel home, advanced settings, and troubleshoot my network.  The option to "Turn windows firewall on or off" is disabled. We have Norton 360, so I opened that program and chose the "Settings" tab, which displays a Firewall link to

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketExcept

  

I have a scenario where there is a web service (WS2) which resides behind WSLX authentication. There is another web service (WS1) which is outside of this WSLX authentication. Now we have blackberry application which calls WS1 & send its login credentials which gets passed to WS2 & token is returned back to the blackberry app. For subsequent request the same token is passed in order to ensure that it is the same session. I have seen the similar error as mentioned below earlier in the log but now after migration to SQL 2005 from SQL 2000 this has become more frequent. The error is:

 

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond     at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)     at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)     at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)    

packing an array of float and send them using raw sockets

  

Hi,

 

I need to send a buffer of 20 float values through the net using sockets, so they're picked up by another app. I thought I had it by using 

 

 private static byte[] SerializeExact(object anything)
    {
      int structsize = Marshal.SizeOf(anything);
      IntPtr buffer = Marshal.AllocHGlobal(structsize);
      Marshal.StructureToPtr(anything, buffer, false);
      var streamdatas = new byte[structsize];
      Marshal.Copy(buffer, streamdatas, 0, structsize);
      Marshal.FreeHGlobal(buffer);

      return streamdatas;
    }

And then

 var udpClient = new UdpClient();
      byte[] sendBytes = null;

      udpClient.EnableBroadcast = true;
      udpClient.Connect(IPAddress.Broadcast, 4023);
      sendBytes = SerializeExact(pack);
      udpClient.Send(sendBytes, sendBytes.Length);
      udpClient.Close();

but found out it does not work (because a float array is not serializable?), is there any other proper way to do it?

thanks in advance.

 


Sockets and mixing IPV4 and IPV6

  

I am creating two applications which communicate via TCP/IP sockets using C# and the .NET sockets library.  Once side create a socket and binds to a hostname and port, the other does a BeginConnect/EndConnect.  When I use both programs on the same machine (Win 7 64-bit) and use the hostname "localhost" and AddressFamily InterNetworkV6, everything is fine.

When I put the listener (the one binding to a port and listening) on a Win XP 32-bit machine, I can only create a socket if the AddressFamily is InterNetwork (IPV4).  It runs and waits for a connection, but on the Win7 machine, when I do the BeginConnect, I get an error:

19673 [10] ERROR CardioInsight.Athena.RMFInterface.CommState.Connecting (null) -
 BeginConnect() fails
System.Net.Sockets.SocketException (0x80004005): The system detected an invalid
pointer address in attempting to use a pointer argument in a call
   at System.Net.Sockets.Socket.DoBeginConnect(EndPoint endPointSnapshot, Socket
Address socketAddress, LazyAsyncResult asyncResult)
   at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback ca
llback, Object state)
   at CardioInsight.Athena.RMFInterface.ClientNetworkInterface.BeginConnect(Asyn
cCallback callback, Object state) in C:\CardioInsight\Athena\trunk\Code\Car

sockets

  
HI,
can someone help me with with this... i need to understand how  server deals with the client objects , when a request comes from a client  and when it  actually disconnects  from the server ..plz i really  need this information...

1. IM WORKING THIS ON .NET 2005(C#), SOCKET HANDLING....

 

WELL , SO FAR , IM FINE WITH THE SOCKETS BASICS, TIME HAS COME FOR ME TO DEAL WITH THE MULTIPLE CLIENTS,  WHAT I WANT TO KNOW IS, WHEN ALL CLIENTS ARE CONNECTED TO THE SERVER,AND IF A CLIENT DISCONNECTS FROM HIS END...HOW TO DETECT OR FIND OUT WHICH CLIENT IS DISCONNECTED , AND HOW CAN I CHECK FROM THE SERVER END... ..AND HOW SERVER HANDLES THE CLIENT OBJECTS  WELL THIS IS REALLY SCARING ME, I HAVE GONE THROUGH MANY ARTICLES, BUT IM NOT GETTING A DEEP IDEA ABOUT  HANDLING CLIENT OBJECTS ON THE SERVER SIDE.....HOW TO IDENTIFY WHEN I LOOSE THE CLIENT...

   PLEASE ..HELP ME WITH THIS,  

REGARDS

VERONICA


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend