Jump to content
Xtreme .Net Talk

Morpheus

Avatar/Signature
  • Posts

    62
  • Joined

  • Last visited

About Morpheus

  • Birthday 12/07/1983

Morpheus's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Im trying to send an serialized object over the network and it doesnt work. Im uncertain if it is the sending part och the recieving part that doesnt work but I think it is the sending part. The code: public class Server { private NetworkStream socketStream; private BinaryWriter writer; private BinaryReader reader; private Thread readThread; private Socket connection; private int port; public Server(int port) { this.port = port; readThread = new Thread(new ThreadStart( RunServer)); readThread.Start(); } public Server() { } public void RunServer() { TcpListener listener; RequestHandler rh = new RequestHandler(); int counter = 1; try { IPAddress localaddr = IPAddress.Parse("127.0.0.1"); listener = new TcpListener(localaddr, port); string message; listener.Start(); Console.WriteLine("Server is running on port " + port); while(true) { Console.WriteLine("Waiting for incomming connections.."); connection = listener.AcceptSocket(); Console.WriteLine("Connection recieved from " + connection.RemoteEndPoint.ToString()); socketStream = new NetworkStream(connection); writer = new BinaryWriter(socketStream); reader = new BinaryReader(socketStream); Console.WriteLine("Sending welcomming message.."); writer.Write(" SERVER>>> Success "); while(connection.Connected) { rh.Operation( socketStream); } writer.Close(); reader.Close(); socketStream.Close(); } } What Im trying to do is sending "socketStream" to another method in another class that serialize the object and send it using socketStream. Can I do so? The recieve part look like this: Customer cust = new Customer(); NetworkStream output; output = client.GetStream(); cust = (Customer)(bf.Deserialize(output)); I get a null value on cust. The network communication works fine, I can send and recieve strings. //Robin
  2. I have an array that is sorted with insert sort: public void InsertionSort() { int inner, outer; for(outer=1; outer<nElems; outer++) // out is dividing line { long temp = a[outer]; // remove marked item inner = outer; // start shifts at out while(inner>0 && a[inner-1] >= temp) // until one is smaller, { a[inner] = a[inner-1]; // shift item to right --inner; // go left one position } a[inner] = temp; // insert marked item } } I want to remove any duplicates with NoDups(). The problem is that it must be an effective algorithm so I can't just shift down one space everytime a duplicate is found. No element should be moved more than one time no matter how many duplicates there are in the array. I would be really thankfull for any kind of tip
  3. Yeah that might be the solution. Thanks!
  4. Sorry I meant the SQL-statement. That class is a base class for GetCustomers and GetSuppliers thought it would be the most logical way to handle requests for customers and suppliers. But maybe its better to handle both customers and suppliers in the same class?
  5. Morpheus

    Override

    I have a method for searching a db: public virtual ArrayList Search(string parameter, string columnName) { ArrayList al = new ArrayList(); myCommand = MyConnection.CreateCommand(); myCommand.CommandText = "SELECT * FROM Customer WHERE" +columnName+ "= '" + parameter + "'"; myReader = myCommand.ExecuteReader(); while(myReader.Read()) { al.Add(myReader); } return al; } How can I use the override to just change the connectionstring?
  6. How can I retrieve my IP-Address during Runtime? For exampel: string myIPAddress = ....
  7. I have a treeview control and I would like to perform certain tasks depending on wich item is clicked in the control. How can I do that?
  8. aha than you very much!
  9. Aha thanks, but how do I do for KeyUp?
  10. How can I check if "KeyUp" is pressed? If I want to check if enter is pressed I just do like this: if(e.KeyChar == 13) { txtAddress.Focus(); e.Handled = true; } but it doesen't seem to be that simple with KeyUp.
  11. Ahh it works now! I changed the link in Service to the new portnr. Thanx for your help
  12. I have one function that access the database directly from the webapplication and it works. So the error occur when the webapplication try to use the webservice. Any ideas?
  13. No that didn't work. Why does everything work on port 80 but not on port 8080?
  14. Well the problem is there. Maybe I have to do like this? sqlConnectionString="data source=127.0.0.1:8080;user id=sa;password="
  15. Yeah that sounds logic. Thank you very much! But my database and IIS is always on the same machine.
×
×
  • Create New...