473,763 Members | 4,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting and concurrent socket connections

Hello

Having been trying to find the root of this problem for several days I
now hope that you can help me.

I'm implementing a distributed file system - consisting of, at the
moment, a testing client (C), a http-server (H) and a file server (F) -
with the following setup:

H acts as an external interface to F, that is any given C connect to
one H in order to access files at F. The communication between H and F
uses remoting, ie. F registers a FileServerObjec t which interfaces the
local file system which acts as the file storage. Testing H and F alone
works fine.
The communication between C and H uses regular sockets and uses the
HTTP1.1 protocol for communication. These two work fine together.

The problem then is when I try to test the system as a whole. When
trying to authorize (using a custom implemented certificate driven
authorization protocol) H suddenly starts to act weird when reading
data from the NetworkStream based on the socket connected to C. It
simply stops reading data at the stream at various points in the
authorization process.

Somehow the remoting setup effects the communication with the clients.
Sometimes all works perfectly, other times certificates or encrypted
secrets are never read at H. How can this be?
No exceptions are ever throws, the NetworkStram.Re ad(...) simply blocks
as no data are available. Have the remoting framework somehow consumed
the data?

I've included the method that reads from the NetworkStream for you to
see.

If you have any questions that would clarify my problem, please feel
free to ask.

private byte[] ReadPut()
{
//Validate for content-length header
if (!_lastRequest. Headers.Contain sKey("Content-Length"))
{
WriteHttpRespon se(HttpResponse Codes.BadReques t, "Content-Length
header missing");
return null;
}
else
{
int contentLength =
int.Parse(_last Request.Headers["Content-Length"]);
//Log("Content-Length: " + contentLength);
byte[] fullContent = new byte[contentLength];

int readBytesTotal = 0;
while (readBytesTotal < contentLength)
{
int readBytes = _networkStream. Read(fullConten t,
readBytesTotal, (contentLength - readBytesTotal < 1024 ? contentLength
- readBytesTotal : 1024));
readBytesTotal += readBytes;

if (readBytes == 0)
break;
}
if (readBytesTotal == 0)
return null;
else
{

//
Console.WriteLi ne(ASCIIEncodin g.Default.GetSt ring(fullConten t));
return fullContent;
}
}
}

Best regards,
Thomas René Sidor

Sep 24 '06 #1
1 1966
Ok, apparently the code does not work even if i disable the remoting
part at this moment. Communication between the client and http server
stops at random, although some data always get send. I.e. I send a http
request with some headers and a body - the headers are read using a
StreamReader created on top of the NetworkStream - this always works
without problems. The problem occurs when reading the body (using the
previously posted method) from the NetworkStream.

Any suggestions as to how this can be?

The client is implemented using HttpWebReqeust / HttpWebResponse and
the server accepts connections using a TcpListener which accepts
TcpClients.

For the purpose of development I have the client start the http server
and file server processes - could this influence on the
networkstream?

Below is the code that accepts new incoming connections.

private void ListeningLoop()
{
Log("Starting HttpServer");
bool exitLoop = false;

TcpListener listener = new TcpListener(new
IPEndPoint(IPAd dress.Parse("12 7.0.0.1"), _port));
// Registering TcpChannel for remoting
TcpChannel channel = new TcpChannel();
ChannelServices .RegisterChanne l(channel, true);

Log("HttpServer up and running. Listening on port " + _port);
listener.Start( );
// Listening for incomming connection to the HttpServer
while (true)
{
// If we for some reason need to stop the server, neat cleanup
can be handled here
if (exitLoop)
{
Cleanup();
break;
}
try
{
TcpClient client = listener.Accept TcpClient();
ConnectionHandl erInstance connectionHandl er = new
ConnectionHandl erInstance(clie nt);
Thread connectionHandl erTread = new Thread(new
ThreadStart(con nectionHandler. HandleConnectio n));
connectionHandl erTread.Start() ;
}
catch (Exception)
{
//Log(e.ToString( ));
Log("Failed to accept connection");
}
}
}
I would appreciate any feedback.

Best reagards,
Thomas René Sidor

Sep 25 '06 #2

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

Similar topics

1
302
by: boxim | last post by:
Hi all, Just some queries re: remoting. I've been asked to write an app where many people may simultaneously open it and share information. Sounds simple enough, and normally I'd use a database, client app and web services for providing the data - however, it needs to be able to share data realtime, like make alerts appear when other users enter data etc and it cant be a peer-to-peer app as the server
2
2496
by: Steven Blair | last post by:
Hi, I have Server application which handles a single conenction froma client. I want this program to accept concurrent connections. Anyone help me out ? I am using a TcpListener object. I thought that this would accept concurrent connections, but apparently not, sicne I have my server running and connect using 2 sessions of telnet and only seems to register one connection.
0
1178
by: Ken Foster | last post by:
I built some remote services, a couple singletons and one single call. On the client side I thought I'd save on connection latency by caching the remote connection in a shared variable. Create it once, then use it as long as my app was running, rather than take the hit on creating and destroying it. The issues that one has with ADO connections staying open didn't seem to apply here. However when there is a lot of client requests,...
1
2692
by: David Krmpotic | last post by:
Hi All! I have a .NET remoting Client-Server application with Server Activated Objects only.. something is worrying me.. sometimes (rarely), I can't connect to the server although it is running. I get the exception saying "A socket operation was attempted to an unreachable host".. it means that it behaves the same as if the server
6
1627
by: AMDRIT | last post by:
Hello folks, I appologize for the cross post, but I really need an answer on this: I do not think that I am seeing the whole picture here. I would like to create a windows service and a management console, using Visual Basic 2003. The windows service part, I think, is easy enough. I am more concerned with the remoting aspect of the project. Below is the general idea of my approach, please correct my where I am wrong.
0
4687
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a number of different types of data coming in. I have a databuffer for each type of data coming in.
6
6450
by: roblugt | last post by:
I have what I imagine is a well-known .Net networking problem, but even though I've Googled for some time I've not yet come across a thread where this has been fully explained... There is a fairly common idiom (at least in the Java/UNIX/Win32 worlds) where a socket connection is established and the program then utilises two threads: one dedicated to reading from the socket and the other one concurrently writing to the socket - both using...
11
8617
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end' functions. I already found that connecting doesn't set the "isconnected" variable correctly...
0
3403
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false); I get the following error - doesn't matter if I try it local from my machine or from a remote machine. (After the Errormessage is more text ;))
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.