• (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

Basic Client/Server Chat Application in C#

#16 XOR  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-November 09

Posted 03 November 2009 - 05:55 AM

View Postamira88, on 11 Oct, 2009 - 01:43 AM, said:

thanks for this tutorial,
i make 2 projects the first one contain the ChatServer class wich is contained b the "PC" name space.The second project contain the ChatClient class .
in the second project i need to use first project so i wrote
using PC;


but i've this ERROR

"The type or namespace name 'PC' could not be found (are you missing a using directive or an assembly reference?) "

what i have to do!
thx



The fastest fix is to change line "using PC;" to somethign like "using PC = ChatServer;" (replace "ChatServer" with your namespace)
Was This Post Helpful? 0
  • +
  • -

#17 unnikrisb  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-November 09

Posted 24 November 2009 - 04:31 AM

Let me check the codes..
Thanks for the tutorial.
Was This Post Helpful? 0
  • +
  • -

#18 drxthirst  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-December 09

Posted 07 February 2010 - 12:46 PM

How exactly would I go about creating a file to host on my server that would allow this chat program to connect to it instead of 127.0.0.1?
Was This Post Helpful? 0
  • +
  • -

#19 Guest_Virko*


Reputation:

Posted 07 February 2010 - 06:52 PM

Is it normal for the app to eat up all the cpu? I am testing this on a dual core machine and the server takes an entire core then the client takes an entire core. Any thoughts?
Was This Post Helpful? 0

#20 merlinfire  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 114
  • Joined: 23-February 09

Posted 22 February 2010 - 06:46 AM

After some tinkering with this tutorial, I realized I was having a problem: sometimes when one client disconnected, it would disconnect the other clients, or even crash the server. I also tried this with a standard telnet client connecting to the server.

The solution I came up with was to use the "lock" directive on the SendMsgToAll method in ChatServer, for the nickName and nicknNameByConnect, to make it a little more thread safe. Then I added some if(tcpClient[cnt].Connected == true) and if(tcpClient[cnt].Connected == false) logic to more predictably remove users from the hashtables and close the tcpClient connection on the server's end. Putting that logic in the catch block was too unpredictable IMO, since it removed users when anything at all went wrong: which was a tricky thing to catch given the fact that all user threads were interactive with the same nickName and nickNameByConnect instance variables.

Hope that helps some folks.
Was This Post Helpful? 0
  • +
  • -

#21 Guest_Laura*


Reputation:

Posted 04 April 2010 - 08:01 AM

I downloaded the source files, I made the server a separate application like you said. I run the server app first, then I run the client. And I get the following error: "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
Any ideas why this is happening? And how could I solve it?
Was This Post Helpful? 0

#22 Guest_Hassan Assalih*


Reputation:

Posted 15 May 2010 - 12:18 AM

can you think of the chat program as a protocol between client and a server, right so you can write the protocol using .Net Protocol Builder in www.protocol-builder.com ???
Was This Post Helpful? 0

#23 Guest_Shawn*


Reputation:

Posted 26 July 2010 - 08:37 PM

This is a horrible project none of the classes fall in line the control you are using are ok, but when you are working with namespaces they aren't properly being recognized I am not sure what version of .Net you are using but I tried this on the 2008 Visual Studio and this code only partially worked and I was not sure if you started this for a Console project which I assumed it was and I really didnt like the clarity of this project it had some inclusions in it. this project did not even work to many errors and the name space PC what was that man come on make a better tutorial and lets get a chat program working.,
Was This Post Helpful? 0

#24 Guest_destro*


Reputation:

Posted 22 September 2010 - 12:44 PM

i lost in the end of Docommunicate.cs class i can't figure out what to do then !!!!
plz after i finish creating this class what shall i do
any help will more than appreciated !!!!
Was This Post Helpful? 0

#25 msrit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-April 11

Posted 01 April 2011 - 07:24 AM

hey in visual studio did u make ur application a console based one or a windows form based one?
n should the chatserver n chatclient in 2 diff applications?
n wat abt docommunication? should it be associated with the chatserver or chatclient?
plz do reply back
i wanna noe how to run the pgm
Was This Post Helpful? 0
  • +
  • -

#26 Sparkling Diamond  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 11

Posted 29 July 2011 - 08:50 AM

Is this tutorial will work in connecting a LAN based game?
Was This Post Helpful? 0
  • +
  • -

#27 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9205
  • View blog
  • Posts: 34,582
  • Joined: 12-June 08

Posted 29 July 2011 - 08:54 AM

With some modification I don't see why not.
Was This Post Helpful? 0
  • +
  • -

#28 Sparkling Diamond  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 11

Posted 29 July 2011 - 09:13 AM

what modification should i do to make to us eit for lan based games.
Was This Post Helpful? 0
  • +
  • -

#29 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9205
  • View blog
  • Posts: 34,582
  • Joined: 12-June 08

Posted 29 July 2011 - 09:52 AM

That's a discussion for a separate thread, and more importantly for you to investigate first! Level up that experience!
Was This Post Helpful? 0
  • +
  • -

#30 Sparkling Diamond  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 22-June 11

Posted 29 July 2011 - 09:57 AM

ok cool
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4