|
James, you did not specify your protocol or connection method.
If you are using a connection-oriented protocol, you must either call Connect to establish a remote host connection, or Accept to accept an incoming connection prior to calling Receive. The Receive method will only read data that arrives from the remote host established in the Connect or Accept method. If you are using a connectionless protocol, you can also use the ReceiveFrom method. ReceiveFrom will allow you to receive data arriving from any host.
If no data is available for reading, the Receive method will block until data is available, unless a time-out value was set by using Socket..::.ReceiveTimeout. If the time-out value was exceeded, the Receive call will throw a SocketException. If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, the Receive method will complete immediately and throw a SocketException. You can use the Available property to determine if data is available for reading. When Available is non-zero, retry the receive operation.
led mike
|
|
|
|
|
Hi Mike,
Thanks for the reply. I open the socket connection to the client as follows:
connectionSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
if (traceFlag)
{
LogMessage(Severity.ER_SEVERITY_INFO_RETURN, myFilename,
"Socket.Open(): Attempting connection to {0}:{1}", hostName, port);
}
try
{
connectionSocket.Connect(hostName, port);
}
catch (Exception ex)
{
Close();
throw ex;
}
The portion of the receive that isn't behaving is as follows:
while (bIncoming[0] != (byte)MessageWrapper.SOM)
{
tryRead = 1;
read = connectionSocket.Receive(bIncoming, 0, tryRead, SocketFlags.None);
}
The above receive loops forever, with zero bytes received. When I debug the properties of "connectionSocket" I see Connected = true and Available is 0. I would imagine this is because the server has initiated a shutdown, however, it appears the framework is not detecting it.
Hopefully the code snippet helps. Let me know if you need more info.
Thanks for your help.
Kind Regards,
James
|
|
|
|
|
I have found that timeouts and keep-alive messages are a must when using socket connections. I know this doesn't answer your question, but did you know that if you have 3 switches in between the client and the server, then the middle switch dies, and your applications will still think the connections are fine until they try to send a message? The spec. for the keep-alive of the so called connection-oriented TCP/IP is optional.
Assert(this);
|
|
|
|
|
I just tried setting "KeepAlive" socket option to true but it didn't have any affect. The bizzare part here is that the lower level (seen through the network trace) shows that the connections is being shutdown by the server. The network layer of the client responds with an acknowledgement, but the Framework doesn't seem to detect it. It is very possible, (and probable) that i am doing something wrong in my code.
I have found in the past that it is difficult to detect that a remote host has disconnected when sending data... Send always seems to succeed unless the TCP buffer is full at the network layer. The "detection" usually comes when the application tries the next receive... but alas.. not in this case...
|
|
|
|
|
Interestingly enough, your post got me thinking, and I added the bold code below.
while (bIncoming[0] != (byte)MessageWrapper.SOM)
{
tryRead = 1;
read = connectionSocket.Receive(bIncoming, 0, tryRead, SocketFlags.None);
Byte[] b = new byte[1];
b[0] = 0x30;
connectionSocket.Send(b, 1, SocketFlags.None);
}
Now, I get an exception that the host has aborted the transaction on the second time through the loop! The first receive appears to be successful, the send is successful, then the subsequent receive fails.
Any idea how to create/catch the exception without the need of a Send? The send will mess up the server when the server does decide to respond properly.
Thanks for your help.
James
|
|
|
|
|
James Smith wrote: The send will mess up the server when the server does decide to respond properly.
James Smith wrote: I would imagine this is because the server has initiated a shutdown, however, it appears the framework is not detecting it.
How is the send going to mess up the server if it already shutdown the socket which caused the whole thing to start with?
led mike
|
|
|
|
|
Hello,
I'm setting up a remoted object and was wondering about overriding the lifetime service. I overrode the method that allows me to define my own lease settings, but I was curious about what happens when I return null instead of the lease. The object is supposed to now have an infinite lifetime if you return null. So if I applied this to a Client Activated object, then every object a client makes will NEVER get garbage collected. Is this absolutely true? If so, is there a programmatic way that the client could tell the server that it is done with the object and it's OK to clean it up, even though the lifetime is set to infinite?
It just seems odd to me that if a client activates 1000 objects and then sets them to null, and heck, even shuts itself down, the server will keep those objects hanging around. I don't want to build in any kind of sponsoring or lease renewal, I just want the object to stay around without keep-alives and 1 call that says I'm done using it. If something bad happens to the client and a couple objects get left hanging around, then so be it.
Assert(this);
|
|
|
|
|
Hello,
I'm using .NET 2.0 and setting up a remoting interface for a Windows Service. I like to be in control of how other applications use the service so I wanted to specify that client applications should only use the remoted object via an interface. My question is - Can I setup a client activated object so that clients don't have to know about the object class type (beyond the interface)?
So far I have made this work for the server activated (singleton) styled remoted object. This works fine using (ISomeInterface) Activator.GetObject( SomeInterfaceType, ....), but when I try something similar with Activator.CreateInstance( SomeInterfaceType, ... ) the system complains I need a MarshalByRefObject type . I understand why it's refusing to activate the object, but I'm wondering if there is a way around this.
BTW: If you are wondering why I want to use Client activated, it's because there is a future possibility of per client session information that needs to be evaluated per call. If each client has it's own object, then the instance can contain the session information. If I had to store per client session information in a singleton it would involve a lot more management complexity (add more code to maintain, slow things down at runtime, etc..).
Assert(this);
|
|
|
|
|
Hi
How can I transform a C++.Net code to a VB.Net code?
I don't want to run a C++.Net code in Visual Basic.Net.
I can program by VB.Net and I learned this language, but now I find a code which is important for me. I want to understand this code.
can you help me?
bye
modified on Saturday, June 21, 2008 6:14 AM
|
|
|
|
|
Reza12 wrote: How can I transform a C++.Net code to a VB.Net code?
Why would you want to? I'm curious. If the C++ code is CLS Compliant, then you can run it directly in any other CLS compliant environment.
|
|
|
|
|
Hy there,my problem is this: I have a shared assembly(dll) that must be used by many applications and I don't wan't to install it in GAC,I wan't to update it manually. So i need it to be 2 directories UP of the applications(..\..\). To achieve this,I had to sign the assembly with a SNK. That wasn't a problem,the problem is that this shared assembly has satellite assemblies for 3 languages. When I run my application,it finds the shared assembly 2 directories up,but it does not find it's its satellite assembly. I noticed that it searches for the satellite next to my app satellite assemblies. Why is that? the satellite assembly should be linked to the shared assembly,so it should look for it,for culture fr for instance, in [shared_assembly_location]\fr
If any one can help me,thanks in advance.
|
|
|
|
|
Hi All,
Could some one explain the three types of JIT
Thanks in Advance
Dana
|
|
|
|
|
|
|
Simply rewording your question like this doesn't answer the question posed to you.
|
|
|
|
|
Which 3 types of JIT compilers?
|
|
|
|
|
My question Is it possible to generate report in hindi (language) format( using anything crystal report or report services of sel server) . Every thing will be in English only report language be in hindi.
|
|
|
|
|
When I select:
1) File-->New-->New Project
2) Other Languages
3) Visual C#
4) Smart Device
One of the selections is 'Windows CE 5.0'
I have installed the CE 6.x SDK, and I so see:
'Platform Builder for CE 6.0'
Have they change the names? Should'nt I also be able to install so that I see 'Windows CE 6.0' under:
1) File-->New-->New Project
2) Other Languages
3) Visual C#
4) Smart Device
If so, how? I have searched all over the web and I not been able to find the answer.
I am go to work through the book 'Microsoft Mobile Development Handbook', but my ultimate target will be an AIM processor running a .NET versin of CE 6.0.
Thanks,
|
|
|
|
|
Hi
I need to track my employee's internet activity. This needs to link to job cards.
Any idea where to start
Regards
Progress is a process , so value it
|
|
|
|
|
You want to use .NET to write a program to do this ?
I'd say your best plan is to hire people you can trust.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
True
But this is Africa my Friend. And I'm in the mood for a challange
Regards
Progress is a process , so value it
|
|
|
|
|
Check out oDesk. They have an application that takes screen shots at regular intervals, exactly for monitoring work. I'm sure it will have something for the internet as well.
|
|
|
|
|
I've just started to work on a windows service with distributed transactions using com+ and have stumbled upon a design question: When is a transaction started?
Is it when the class is created or when a method is invoked. Consider the example below:
[Transaction(TransactionOption.Required)]
public class TransactionTest : ServicedComponent
{
public TransactionTest()
{
}
public void BeginLoop(int count)
{
for (int i = 0; i < count; ++i)
MakeTransactions();
}
[AutoComplete]
private void MakeTransactions()
{
if ((new Random()).Next(10) < 4)
ContextUtil.SetAbort();
else
ContextUtil.SetComplete();
}
}
A simple transaction based class with a method that is being invoked multiple times internally. Are all calls to MakeTransactions() in the same transaction or is a new transaction started each time SetAbort/Complete is invoked?
|
|
|
|
|
Short answer is I don't know. I know there is a difference between starting a transaction and participating in one. The code you posted could result in only a single transaction being started and multiple participations in the transaction.
There are many resources available on MSDN for the Transaction topic that you may want to dig into.
led mike
|
|
|
|
|
I can only point you to Tim Ewald's excellent book Transactional COM+[^]. Note that this only covers COM+ up to Windows 2000, and the little information it has on .NET is out of date (it was published in 2001), but the core information is very much correct.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|