|
Thanks N a v a n e e t h,
Looks like both of them are wrapping native mutex handle?
regards,
George
|
|
|
|
|
Hai,
Am doing Live chat project in c# using sockets. In that client server interaction(1 to 1) is ok. More than one client is connected (1 to n) to server then problem is if am sending message from server its going to all clients. But i want to send message to particular user. Please any one help me.... sample code for start Lisening in socket...
private void StartListen_Click(object sender, EventArgs e)
{
try
{
string portStr = textBox2.Text;
int port = System.Convert.ToInt32(portStr);
Create the listening socket...
m_mainSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPEndPoint ipLocal = new IPEndPoint(IPAddress.Any, port);
m_mainSocket.Bind(ipLocal);
m_mainSocket.Listen(4);
m_mainSocket.BeginAccept(new AsyncCallback(OnClientConnect), null);
UpdateControls(true);
}
catch (SocketException se)
{
MessageBox.Show(se.Message);
}
}
Thanking you,
Regards,
Nvrk
|
|
|
|
|
Hello everyone.
I am a relatively new and novice programmer, having only been programming for a few months.
I am trying to figure out what is going wrong with my simple TCP client / server program.
The server reads the bytes from a file, and sends them over a socket to a client, who reads the bytes into a buffer and outputs the bytes to the screen. After a while of doing this successfully, however the data read off the socket is nothing more than a bunch of zeros. After the correct amount of bytes has been read from the socket, it blocks as it expects more data and produces a timeout exception.
My code is as follows:
static void Main(string[] args)
{
if (args.Length > 0)
ServerMode();
else
ClientMode();
}
private static void ServerMode()
{
Socket listen = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint iep = new IPEndPoint(IPAddress.Any, 8888);
listen.Bind(iep);
listen.Listen(3);
Socket sock = listen.Accept();
byte[] data = File.ReadAllBytes("C:\\bmptemp.bmp");
NetworkStream ns = new NetworkStream(sock);
ns.Write(data, 0, data.Length);
while (true)
{
int i = 2 + 2;
}
}
private static void ClientMode()
{
int recv = 0;
int totalRecv = 0;
Socket connect = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
connect.Connect(IPAddress.Parse("192.168.1.13"), 8888);
NetworkStream ns = new NetworkStream(connect);
do
{
byte[] data = new byte[1024];
recv = ns.Read(data, 0, data.Length);
totalRecv += recv;
foreach (byte b in data)
Console.Write(b.ToString() + " ");
}
while (recv > 0);
Console.WriteLine("Bytes read: {0}", totalRecv.ToString());
Console.ReadKey();
}
If the arguments passed into the command line are greater than 0, ServerMode is started, whereas client mode is started.
I would just read all of the bytes in one lump sum by making an overly large buffer to place the data in, but I wish to do it in small chunks like above so that I can add a progress bar and estimated time of completion to the simple program.
Any ideas as to why this doesn't download off of the socket properly? Any help, thoughts, or comments are greatly appreciated!
|
|
|
|
|
Hi
In a standalone windows app, I create a table, add rows to it, populate a couple of rows and add the table to a dataset.
I bind the table in the dataset to a datagrid.
If I make changes to the grid, the contents of the table are updated and the rowstate is set to modfified.
In a client/server situation, I fill a dataset with a table from a database and pass the dataset to the client.
On the client side I bind the table in the dataset to a datagrid.
The datagrid displays the data.
But if I make changes to the datagrid, no changes are made to the dataset.
In both cases I use
gridUsers.SetDataBinding(dsUsers,"UserList")
Where does the difference come in?
Just say if you need code snippets.
Obviously, until I can get the dataset to reflect changes made to the datagrid, I am going nowhere with developing this app.
Thanks,
Nigel
|
|
|
|
|
i think u need to call AcceptChanges() method on dataset
rahul
|
|
|
|
|
The point is that there aren't any changes in the dataset. That is the whole problem, changes made to the grid contents do not change the dataset.
|
|
|
|
|
|
Thanks, but I can do that just fine. This example is all on one Windows form. The problem occurs when I fill a dataset from a database at the server, send the dataset to the client, and the client binds the dataset to a datagrid.
When I do this, the datagrid does not update the dataset.
If I create a windows form with a datagrid on it, and fill the dataset using code on the same form, then changes to the datagrid update the dataset.
It is as if the compiler knows that the dataset was passed over the network and refuses to implement the data-binding in both directions
Nigel
|
|
|
|
|
im doing a project about RFID system registration..
database-ms access
database name=registerDBDataSet
table=ASAS
column=GAMBAR
in my form i have a gambarPictureBox,which retrieve the image from my pc(use browse button) from openFileDialog..
when run the program the image is open in the pictureBox and i want to save the image to database..
which way can i use?
since many coding that i search from internet using sql command,is there any other way to retrieve image from picture box and insert it into database?
the error happen when this code run:
private void saveButton_Click(object sender, EventArgs e)
{
this.aSASTableAdapter.Insert(nameTextBox.Text, tptLhrTextBox.Text, trhLhrTextBox.Text, jantinaTextBox.Text, kaumTextBox.Text, agamaTextBox.Text, wargaTextBox.Text, statusTextBox.Text, ICTextBox.Text,gambarPictureBox.Image);
this.aSASTableAdapter.Fill(this.registerDBDataSet.ASAS);
}
---->Error 1:The best overloaded method match for 'Registration.registerDBDataSetTableAdapters.ASASTableAdapter.Insert(string, string, string, string, string, string, string, string, string, byte[])' has some invalid arguments
---->Error 2: Argument '10': cannot convert from 'System.Drawing.Image' to 'byte[]' C:\Documents and Settings\fathiah.FATHIA-582A635D\Desktop\Registration\registerForm.cs
how to solve it..
please help me..
|
|
|
|
|
you need to save the picture as bytes not as system.drawing.image object. the Dtabase don't know object there are just 0 and 1
But please don't ask me how to convert a image into a byte array...
|
|
|
|
|
as both errors indicate - the last parameter expects a byte array (byte[]) but your passing an Image object. Convert the image to a byte array first (maybe by saving to a memory stream? - google for best solution!) then pass that to the method instead.
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
gambarPictureBox.Image.Save(memStream, gambarPictureBox.Image.RawFormat);
byte[] imageBytes = memStream.ToArray();
To load you'll have to do the reverse.
Dave
modified on Monday, June 2, 2008 6:37 AM
|
|
|
|
|
|
Hi there!
I finally got XP worked with win2k before. Iv'e installed VS2005 and though it could go on. i compiled my project (succeeded)[edit] c# framework 2.0.50727 [/edit]
press F5 and then........
"..Error while trying to run project....<br />
<br />
This application has failed to start because the application configuration is incorrect. Review manifest file for possible errors. Reinstalling the application may fix this problem. for more details, please ssee the application event log."
I think you know this message at all (I googled it, searched in several forums, tried the suggestions but no success at all)
Could someone give me a clue how to fix this error? i allready looked up in securty.config, manifest and spended 2 days to find a solution at all....
thanks in advance
Mathias
|
|
|
|
|
What does it say in the event log? It sounds like a missing dll - or one not in the expected location.
Dave
|
|
|
|
|
by event log you mean the manifest file don't you?
mathias
|
|
|
|
|
In the error that the OP posted it finished "please see the application event log" - so I figured that would be a good place to look!
Dave
|
|
|
|
|
You're saying that you've searched for the answer with no success for 2 days , but you didn't repair/reinstall, like the suggestion says?
I wouldn't have waited for more than 2-3 hours before I did a reinstall.
|
|
|
|
|
ähm are you sure you are a developer?? MY .exe should be reinstalled not VS2005.... so how will i reinstall a application that I'm developing in the moment??? if you could say me that i will become a rich man.
but thanks anyway found the error:
ClickOnce Securty Settings were enabled. I don't know why but I'm happy that i found this "bug"
thanks for your suggestions
|
|
|
|
|
Hi All,
I have given an interview. They asked me one question on OOP concept.
I could'nt able to answer, can anybody help me to find the solution?
Question
class a
{
private double myclass()
{
//coding stmt;
}
}
This class is kept in dll.
In main class you want to call method myclass how you will call b'coz that class is private method.
|
|
|
|
|
It's not possible to call the method directly as it is private. You may use reflection to do this, I guess.
|
|
|
|
|
The answer is that you don't, private members are accessible from inside that class only. You can work around this using reflection but unless you have no other choice you really really shouldn't do this.
|
|
|
|
|
You can do this using Reflection, but in an interview it's always worth pointing out that you SHOULDN'T do this because this is breaking the basic reasoning behind making a method private.
|
|
|
|
|
There's an easier answer than reflection: Add another function in class a that's public and calls myclass():
public double getMyClass ()
{
return myclass ();
}
Yes, it's a silly answer, but that was a silly question.
|
|
|
|
|
I want Visual Studio to auto-change the active project when I change sourcefiles. I don’t want to right-click a project an choose ”Set as startup project”. (VS 2005)
_____________________________
...and justice for all
APe
|
|
|
|
|
d00_ape wrote: I don’t want to right-click a project an choose ”Set as startup project”. (VS 2005)
so how does it know what you want to do? Guess?
Bob
Ashfield Consultants Ltd
|
|
|
|