Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
GeneralC# sql query problem Pin
Member 412921825-Apr-08 20:10
Member 412921825-Apr-08 20:10 
GeneralRe: C# sql query problem Pin
Christian Graus25-Apr-08 20:28
protectorChristian Graus25-Apr-08 20:28 
GeneralRe: C# sql query problem Pin
Derek Bartram26-Apr-08 7:34
Derek Bartram26-Apr-08 7:34 
GeneralRe: C# sql query problem Pin
Christian Graus26-Apr-08 11:11
protectorChristian Graus26-Apr-08 11:11 
GeneralRe: C# sql query problem Pin
Derek Bartram26-Apr-08 11:50
Derek Bartram26-Apr-08 11:50 
GeneralRe: C# sql query problem Pin
Christian Graus26-Apr-08 11:53
protectorChristian Graus26-Apr-08 11:53 
GeneralRe: C# sql query problem Pin
Derek Bartram27-Apr-08 0:07
Derek Bartram27-Apr-08 0:07 
Question.NET Sockets Problem [modified] Pin
Mike Bentzen25-Apr-08 16:03
Mike Bentzen25-Apr-08 16:03 
Hello Everyone.

I am currently having a lot of trouble with .NET sockets.

I am trying to create a client with a windows forms interface. I have attempted to create a communication class which basically contains some functions for connecting and managing the connection.

public class connection {<br />
<br />
private TCPClient _client = new TCPClient();<br />
<br />
public bool Connect(string hostname, int port) {<br />
   try {<br />
        _client.Connect(hostname, port);<br />
        return true;<br />
   } catch {<br />
   return false;<br />
   }<br />
}<br />
<br />
public bool IsConnected() {<br />
   try {<br />
        if (_client.Connected) {<br />
        return true;<br />
        } else {<br />
        return false;<br />
        }<br />
   } catch {<br />
   return false;<br />
   }<br />
}<br />
<br />
}<br />
<br />


Is a really basic connection class. I have multiple forms which I would like them to be able to control the connection and receive and display information on them.
I understand that the usual way for all form instances to access the same things, is to declare those things as static. I have tried to make this class a static class but the TCPClient throws an error telling me that you can't have a static instance. I don't want multiple instances of this class. The client only needs to handle one connection at a time.

I have gone through all C# tutorials and articles on code project, and they are really helpful if you are only using one form (with delegates) and custom event handlers. I want to be able to receive information from the socket, deserialize the data and use that data to populate classes, and form controls (for example: list box - of connected clients.)

I would really appreciate it if you could explain why I can't have a static instance and maybe possibly links to tutorials or code samples of something similar to what I am describing above so I can try to understand how it works.

Kindest Regards,

Mike

modified on Friday, April 25, 2008 11:20 PM

GeneralRe: .NET Sockets Problem Pin
Derek Bartram26-Apr-08 7:42
Derek Bartram26-Apr-08 7:42 
Generalchange font colour in richtextbox using timer. Pin
kamalesh574325-Apr-08 15:30
kamalesh574325-Apr-08 15:30 
GeneralRe: change font colour in richtextbox using timer. Pin
mav.northwind25-Apr-08 22:12
mav.northwind25-Apr-08 22:12 
QuestionPath of running application. Pin
Member 404498825-Apr-08 14:16
Member 404498825-Apr-08 14:16 
GeneralRe: Path of running application. Pin
Anthony Mushrow25-Apr-08 14:47
professionalAnthony Mushrow25-Apr-08 14:47 
GeneralRe: Path of running application. Pin
Derek Bartram26-Apr-08 7:44
Derek Bartram26-Apr-08 7:44 
GeneralRe: Path of running application. Pin
Member 404498828-Apr-08 20:38
Member 404498828-Apr-08 20:38 
GeneralRe: Path of running application. Pin
Derek Bartram30-Apr-08 5:29
Derek Bartram30-Apr-08 5:29 
GeneralRe: Path of running application. Pin
Member 404498830-Apr-08 6:00
Member 404498830-Apr-08 6:00 
GeneralRe: Path of running application. Pin
Derek Bartram30-Apr-08 6:27
Derek Bartram30-Apr-08 6:27 
GeneralRe: Path of running application. Pin
Member 404498830-Apr-08 10:25
Member 404498830-Apr-08 10:25 
GeneralRe: Path of running application. Pin
Derek Bartram1-May-08 1:59
Derek Bartram1-May-08 1:59 
GeneralRe: Path of running application. Pin
Member 40449881-May-08 9:15
Member 40449881-May-08 9:15 
GeneralRe: Path of running application. Pin
Derek Bartram1-May-08 9:48
Derek Bartram1-May-08 9:48 
GeneralGet/Set object properties using 'System.Reflection' Pin
Lea Hayes25-Apr-08 13:10
Lea Hayes25-Apr-08 13:10 
GeneralRe: Get/Set object properties using 'System.Reflection' Pin
Derek Bartram26-Apr-08 7:47
Derek Bartram26-Apr-08 7:47 
GeneralRe: Get/Set object properties using 'System.Reflection' Pin
Lea Hayes27-Apr-08 4:10
Lea Hayes27-Apr-08 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.