|
If you want, you could call Receive on a background worker thread, but that would entail multiple threads.
The bottom line is that Receive will behave synchronously, meaning it will block when there is no data.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is there a way to check the data in the socket and call Receive() only when data is available for receiving. This way it should not block, right?
|
|
|
|
|
I see that Socket has a method called Poll . Take a look:
Socket.Poll[^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks. The Poll() method really helped. I'm now polling for three seconds before receiving for both client and the server. However, there is still some logical issue with my code:
if (client.Poll(3000 * 1000, SelectMode.SelectRead))
{
rec = client.Receive(buffer, buffer.Length, SocketFlags.None);
Debug.Print("RECEIVED FROM CLIENT: " + Encoding.ASCII.GetString(buffer, 0, rec));
sent = webserver.Send(buffer, rec, SocketFlags.None);
Debug.Print("SENT TO WEBSERVER[" + sent.ToString() + "]: " + Encoding.ASCII.GetString(buffer, 0, rec));
transferred += rec;
}
else
{
Debug.Print("No data polled from client");
}
As I said, one logical fault still remains. In the proxy client machine, I'm able to open google.com. Then performed a search that also went fine. However, when I click on a search result, the proxy again gives me google.com!! What am I missing?
|
|
|
|
|
If i want a simple server to client communication as a background service on windows Os, that would only send ISP infor to a hosted domain, WHERE would i start? C# or VB.net or other? Which has an example or godd start?
Experience is the best teacher
|
|
|
|
|
kipchirchir wrote: WHERE would i start?
By explaining that in terms we can understand?
kipchirchir wrote: C# or VB.net or other?
Whichever you know and are comfortable with.
VB and C# are interchangeable, pretty much, anything you can do in one, you can do in the other.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
See my answer in the .NET forum; BTW, please do not post the same question in multiple forums.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
If I do something like this
XElement root = new XElement("Root",
new XAttribute("Att1", "a"),
new XAttribute("Att2", "b"),
new XAttribute("Att3", "c"));
XDocument document = new XDocument(root);
document.Save("file.xml");
Instead of it writing
Root Att1="a" Att2="b" Att3="c"/
it writes Root Att3="c" Att2="b" Att1="a"/
Even in debugging mode when I look at the XML contents of document it appears to be in the proper order, but when it writes to file it reverses them. Can anyone tell me why it is doing this?
|
|
|
|
|
Efficiency, I guess. Does the order matter?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Considering XML doesn't give a rats ass about the order of attributes, what's the problem?
|
|
|
|
|
Nukeman33 wrote: Can anyone tell me why it is doing this?
You have a bug either in implementation and/or requirements if you think that the order matters.
|
|
|
|
|
The logic behind writing to the file may be the culprit.
I guess if the order is not important to you, just ignore it!
|
|
|
|
|
|
"Hello" is hardly a question; I can see the question in the subject-line, but it would not have cost you that much time to repeat it in the body and add the code that you're currently working on.
Now, back to the problem, why would you need "multiple" timers?
Imagine you are cooking, and you need to time the eggs (7 minutes) and the pudding (10 minutes). That means you'd use two people, one to warn you after 7 minutes, one after 10 minutes.
Alternatively, you could ask a single person to look at his watch every minute and have him poke you on both the 7-minute marker and the 10-minute marker. That would save the overhead of having to feed another person; or create another object
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
How i can get all instance in special IP in my network.
I have ip address 192.168.0.2 and wanna get all sql instance .
Thanks in advanced!
|
|
|
|
|
Check out SqlDataSourceEnumerator.Instance.GetDataSources method. You can also have a look at this[^] article.
"Fear no factor", Prime Numbers.
|
|
|
|
|
thanks in advanced !
But no use ! Only return SQL Instance of some Ip address. I have 10 Ip(10Pc) but this only return just 1 of them!
What is the solution?
And One more thing.
Some of my SQL Instance doesnt have user/Pass . i mean they are windows authentication(Integrated Security=true) in some IPs.
|
|
|
|
|
Hi,
I have an App.config in my WinForm application. I want to ask if it's possible to output the App.Config file as DLL?
and how?
|
|
|
|
|
You want to magically transform your app.config text file into a DLL? Why?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
to make it protected so no way for anyone to open it and read the contents...
|
|
|
|
|
Would make more sense then to encrypt it. If you add it as a resource then you would have to write it to disk before you could use it, where it would be vulnerable.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
You can read your configuration file by opening it up with ConfigurationManager.OpenExeConfiguration.
|
|
|
|
|
You miss the point of a .config file, it is supposed to be readable.
If you want to protect your settings then move it to a Setting table in the database or use encryption as suggested.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
how can we detect from inside of our own program that
internet connection is now active or not?
|
|
|
|
|
TcpClient has a Connected property. Is that what you are looking for?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|