|
Ok, my immediate advice would be to do the following:
1) Put the client connection into a new thread - for this you will need a new class with a member for the TcpClient object and a function for the thread. Reasonm being i think the Read function blocks the thread until it gets some data so your accept wont be getting called - unless the Accept also blocks, im not sure.
2) The ocrrect way to accept the connection you need to first see if a connection is pending, there is a Pending property/function on the listener, if this true then accept the connection, create a instance of the client thread class mentioned above - set a member variable of the class to the connection and start a new thread using the thread function you need to create in the new class. This leaves the server thread still available to accept more incoming connections. You need to keep track of the thread count and the _mbCloseThread information now, you could create a static instance of the data in another class and access it like that or pass in class with the thread counts and just make them public.
3) When receiving data from the client connection, you may want to read how much data is available and read the data accordingly, or you could use a BinaryFormatter and pass around an 'Envelope' (dont know if its the right terminiology but it fits!) object which is a wrapper class you create to store the data you want to send, eg:
Public Class MyEnvelope
{
string Data
}
Set the Data to what you want to send then use the BinarryFormatter to serialize it into the NetworkStream of the connection, and on the receive end, you can Deserialize from the stream.
Sorry if this doesnt make all much sense! I have just woken up!
If you are still having trouble I will email you a simple client/server test service in C# I havent got one to hand at the moment, but I could put one together later.
Cheers, James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
Thanks James,
I will try it then tell you about the result.
cheers,
Baqer
|
|
|
|
|
Hi James,
I am still having the same problem. The issue that the client software who sends the information is not written by me it is software provided by customer. Which send a string & receive a string as acknowledgement.
now the question is does it mater if you send the data binary or string coz as you know the write or send method of the socket is accepting byte anyway I have used as well the Networkstream.write which send as string.
James if you have any code can help or if you have any other way to be done please suggest.
I need this service to work.
Best Regards,
Baqer
|
|
|
|
|
I can send you a basic server service which will echo a response to a telnet client?
I will need your email address tho. If I get that address tonight I will email you the service tonight.
J
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
hi,
I need to disable the scrollbars of the MDI parent form. For this I set
the AutoScroll, HScroll and VScroll properties of the MDIForm to false.
But this doesn't work.
In VB this works but in C# it doesn't.
Any clues?
Thanks,
peenu.
|
|
|
|
|
I need to do the same thing...did you ever figure it out?
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
I want to load and unload a dll-file as an assembly dynamically.
how can I realize it? I only know that I have to use AppDomain, but I don't know how. So can anybody help me?
The content of the dll is a windows form. I used the following code before, but it isn't able to unload:
<br />
Assembly SimpAsm = Assembly.LoadFrom(strFile);<br />
frmTemp = (Form)SimpAsm.CreateInstance(strForm );<br />
frmTemp.Show();<br />
try to help me, please! thanks....
|
|
|
|
|
|
yes there's written many information, but not the real code, which I need.
has anybody an example of using AppDomain?
|
|
|
|
|
Anyone tried it ? is it worth the extra money going from proffessional ?
Space reserved for wit , humour and correct spelling.
|
|
|
|
|
I made my custom control.When I use it ,very SELDOM my controls are missing form my form.I can not understand the reason.
|
|
|
|
|
Hi!
I have a very odd problem. In the code segment below (from my webapplication) the bool protected variable bNyPost is set to true in Page_Load but when I click Save the variable is false in the procedure SaveUhItem(). Isn't bNyPost global to all the procedures in the class FelRegMobileForm?
namespace DeDUWebMobile
{
public class FelRegMobileForm : System.Web.UI.MobileControls.MobilePage
{
protected bool bNyPost;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
.
.
.
bNyPost = true;
}
}
.
.
private void CDSave_Click(object sender, System.EventArgs e)
{
SaveUhItem();
bNyPost = false;
}
.
.
private void SaveUhItem()
{
if( bNyPost ) //Is false even though I assigned true in Page_Load
{
.
.
}
}
}
}
MSc Bertil Morefält
|
|
|
|
|
Let me try to explain. Each time a client makes a request to the server a new Page object is instantiated and the Load event is executed. If it's the clients first request for the page the IsPostBack property should be false, but if a control is manipulated (ie. a button is clicked) or if there is some other event that causes the client to post back to the server then the IsPostBack property will be true.
So in your situation the bNyPost variable is getting set to true because it is inside the conditional statement.
Brian
|
|
|
|
|
That's right, but when bNyPost is set to true the first time when IsPostBack is false, it should stay true when tested in SaveUhItem() when I click Save-button as the next action, but it don't.
Bertil
MSc Bertil Morefält
|
|
|
|
|
No, a new Page object is created for each request. Thus, those members of the object that are not placed in the viewstate will not maintain their state. You'll have to place that variable in the viewstate manually or use some other form state management.
Brian
|
|
|
|
|
i try to write a little setup, which supports 3 install options (checkbox).
I would like to know the states of my checkboxes, but it seems like i can't
write something like this
((CHECKBOXA1 And CHECKBOXA2) And Not (CHECKBOXA3))
Option 1 checked, Option 2 checked, Option3 unchecked
Does anybody know how to write something above the right way? It seems like
CHECKBOXA3 has no value (null) if it is not checked. Is there any null
keyword for installer conditions?
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
the syntax of using checkbox is:
checkbox.checked = [true / false];
and then you can control it with "&&"...
|
|
|
|
|
Hallo ich_bins,
i guess you mean the System.Windows.Forms.CheckBox , right ?
what i'm looking for is how to use installer conditions to fire custom actions in a msi setup project.
Thanks for your answer
.:[Greetz from Jerry Maguire]:.
|
|
|
|
|
In my application, I want the user to be able to customize the path to some files.
So I use a OpenFileDialog, and get the path of the new file, and I can open the file.
I'd like to store the path for the next use of the program, but I want to store it relatively to my executable.
But the OpenFileDialog return the absolute path.
So if I have:
e:\Programs\MyProgram\Bin\MyExecutable.exe
and the user select
e:\Programs\MyPrograms\Graphics\MyFile.gif
How can I easily find that the path to store is
..\Graphics\MyFile.gif?
|
|
|
|
|
In shlwapi.dll there is a method called PathRelativePathTo .
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Hello,
Is the format used by BinaryWriter and BinaryReader portable for standard data types like string and uint?
For example, suppose that one uses a BinaryWriter on a machine of type X to write to a NetworkStream, and the other end of the stream is running on a machine of type Y and uses BinaryReader to read from the NetworkStream. Suppose also that both machines are using programs written in C# and being executed by .NET. Will the reader get what was written, regardless of whether X and Y are different types of machines (possibly having different endianness)?
(The BinaryWriter constructor allows one to specify an encoding. I would like to know whether the default encoding is portable in the way described above, and whether the other standard encodings are portable in this way.)
|
|
|
|
|
In answer to your primary question, BinaryReader will read streams created by BinaryWriter correctly.
Your question about endianness is meaningless at the present time because .NET only runs on Intel CPUs and hence you don't have to worry about it. Once Microsoft target .NET for other CPUs then, yes, the .NET Frameowrk team will have to worry about how the stream is created and used between different endian CPUs.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Julian,
Is there complete BinaryWriter/BinaryReader compatibility for all Microsoft .NET implementations and for all pairs of machines that Microsoft's .NET runs on? I tried to be explicit about this in the original post -- if the question is still not clear then I will try to make it clearer. I am looking for an explicitly-written answer that's more informative than, "Some BinaryReader objects can read what's written by some BinaryWriter objects."
The endianness question is meaningful at present because there are different vendors, e.g., Microsoft and Mono, but even information only about Microsoft-to-Microsoft communication would be helpful.
Also, it helps and is even necessary to have some idea of future capabilities. I do not want to release software only to find out in 3 months that a large class of users cannot connect to a server because BinaryWriter and BinaryReader are incompatible in some circumstances, e.g., .NET 2.0 (say) is using a format that is incompatible with .NET 1.0. In fact if this were to happen, then using BinaryWriter/BinaryReader would be painful for many client/server situations because there would be two different classes of users, e.g., many Windows XP users with .NET 1.0 and some other users who are using .NET 2.0. It would become necessary to somehow know in advance which version of the protocol to use, and to be able to use either version within a single assembly (the server).
Andrew
|
|
|
|
|
Andrew
I'm sorry, I see I wasn't being explicit enough <g>. Any stream written with any existing BinaryWriter can be read by any existing BinaryReader. I can even confirm that fact with Whidbey's BinaryReader and Writer (that is, with .NET Framework 2.0). If it didn't then it's a bug. (So the 3D matrix of 1.0, 1.1, 2.0 frameworks, for the two layers of writers and reader combinations has ticks in every cell).
That's the statement about Microsoft's .NET Framework. I know nothing about the Mono project (apart from what it is, of course). I have no idea whether their BinaryReader would always work with a stream createed with BinaryWriter. Similarly I don't know if a stream written by Mono's BinaryWriter would be readable with MS's BinaryReader. However, I would *guess* that the Mono people would have taken endianness into account when they were writing their reader and writer.
Now, as to the future (beyond Whidbey): it would make sense for the .NET Framework team to make sure that BinaryReader and BinaryWriter can continue to work as before. Why? Because the ResourceManager uses BinaryReaders and Writers internally. And that would be bad if Visual Studio .NET X (for X>2) couldn't read resource files from existing projects.
Also, the format used by BinaryWriter is very, very simple and easily reverse engineered. There's no wierdo enums or class names being put in there or stuff like that. An int is written out as 4 bytes, a double as 8, etc, etc.
So, although neither I nor anyone else can really tell you what would happen five years down the road, I wouldn't worry about it.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Thanks Julian. That is just what I wanted to know.
Andrew
|
|
|
|