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


Post New Web Links

sockets

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :.NET Framework
 
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




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; }

.NET Sockets and the firewall.

  
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?  

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

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

  

Hello sam , thanku for responding

 

 well i understood what you are trying to explain , but the thing i want to know is , when  client's c1, c2 , c3 are connected to the server.. if c1 is disconnected , ,at which point exactly i get the exception ,  and how to handle it..?. for u to have an idea , im posting the sample code, which i tried..... ...[ please don mind ,  it seems to be very difficult for me to understand the concept , but if u can help me, really i will be the happiest person.]

first, im not very good  at english, please bear with me...

1. the first thing i did was, i created a worker_socket array  which holds all the clients ..[but im really not sure how internally it saves the clients objects ..]..

and when client gets disconnected , how it deals with that, and will it check back with the array ?, and after that how will it dispose it.? ..i dont know what im doing..but im really requesting u ,i need  this favour  from u...can u please explain in detail.. it seems to be easy , but i dont have any clue of wats going on... so , i will wait for ur reply...

 

code:

using

sockets

  

Hello Everyone...Well Im Totally New to this sockets concept, it Seems to be Easy, Just seems,but it is difficult to understand,well finally i started working on it(multiple clients) .and i have come accross some issues..lets say i connect  5 clients, when they get connected to my server , i m adding the client objects to  a socket array, i  make those objects NULL when i disconnect the clients , so when i start connecting one by one , when the first client lands on the server, Connection method will be called, and there shows an error which Looks something like this......."EndAccept can only be called once for each asynchronous operation" ..so can anyone of u tell me know whta's happening...  .if ur time permits, please send me the reply....Thanku Once again

 

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