C# Multi-Client socket Chat Application - c#

I'm a newbie C# socket programmer and I'm trying to create a C# socket chat application...
here are the requirements of the app..
*it can accept more than one client.
*it should handle those new client on a separate thread.
*the server has a list of active clients and displays them in a list(GUI)
*the server should know when a client is disconnected and will remove it from the list(probably a hashtable or array) of active clients.
honestly, I don't know where to start.
I've been reading through various articles on the net about sockets, multithreading and the likes, but I'm still a bit confused about the whole client/server interaction thing..
Any help/suggestions will be greatly appreciated.. :D

Take a look at ZeroMQ. It was designed for applications like you're describing, works very well, and is free.

Related

Communication between C# application and iPhone app

I googled now a few days and didn't find a good solution for me (maybe I am too bad...).
I have an C# application which have data what the iphone app wants.
So I am logging in on my iPhone app and the C# app should send data.
So I need a central server who handles the requests. But this is my problem I dont find a good solution.
If it would be in a local network I would do this with sockets. But I want to do this over the internet.
I read about php socket server.
But if I have a server with a static ip, can I run a self written C# socket sever on a vm?
Thanks for help!
You don't say how much data you want to transfer. If it's not that much, you might consider a message queue. You can set up a free account at http://www.iron.io/mq to test with. Their free account is pretty generous, so depending on your needs, it might work as a permanent solution as well.

New to C# socket programming

I am new to socket programming with C#. I am developing a client-server application with multiple clients. I am not quite sure how to form a communication between the server and its clients.
Is it a good idea for the clients to send keyword messages (i.e. 'string') that will invoke the server to do something?
Is it a good idea for the clients to send instances of certain classes (that I created) which need to be processed?
Is it a good idea to send/receive files (I am using XML) between the server and the clients?
I am sorry if my questions are naive as this is my first experience developing an application with a client-server architecture.
I found this link which has an example of such an application but I was wondering if anyone knew any other websites/books/tutorials with explanations.
If you create a modern c# application you seldom need to resort to plain sockets to create a client-server application. Instead you can create a WCF service. (Pick a tutorial and try).
Using a WCF service instead of plain sockets will save you from a lot of plumbing work with creating a protocol, parsing and that kind of stuff.

C# Simple DataSocket Example Needed

I am new to C# Socket programming. I am trying to build a simplistic application that can detect when a client application connects to the server application.
When connected, I want to send 1 piece of information to the server and receive 1 response back (confirmation).
Afterwards, I just want to know when the connection is broke. Within my application, I do not have to know instantly when the connection is broken, just within the timeout if fine.
Can someone please help me understand what I need to do to accomplish this. Sample source code would be nice, again I am a novice programmer and this topic is way above my head.
I would need help with the client app and server app.
Thanks in advance!
Jorel
I would not begin with sockets if I were a novice programmer. It's not an easy subject to start with, and you need to know more than just how to send a piece of information. You need to know how the protocols work too and how do deal with their way of send/receiving information.
I would recommend you to use wcf instead, since WCF takes care of all lower level details for you. You will just need to know how to send and receive information.

.NET and P2P - writing a P2P messenger

Does anyone have any advice how to write such app? Or maybe knows some nice tutorial? I would like to use System.Net.PeerToPeer namespace, but everything I can find about it is MSDN which I can't read without getting mad. Or maybe using "old-school" TCP/IP would more efficient?
I will appreciate every piece of advice. Every sample code I will shower with gold ;)
And please, don't send me back to Google for I have searched for a long time for sth useful - maybe inaccurately but time is running out and I really need some help.
[edit]
What about the Brunet library? Has anyone used it?
There is a sample at MSDN that you may find interesting: Peer Channel Chat.
Quote from the page:
The Chat sample demonstrates how to
implement a multiparty chat
application by using Peer Channel.
Messages sent by any instance of a
chat application are received by all
other instances.
The Chat sample is not based on the
concept of client and service. It is a
true peer-to-peer application with
each instance acting as a peer of
other instances. Each instance can
send messages to other instances and
receive messages from other instances
using the IChat duplex contract.

Sending & Receiving "Nudges" via tcp?

I'm tyring to add a feature to my app that sends a nudge to all users of my program (family members inside the house), and when they receive the nudge the window of my app on their computer shakes for a second...
Can somebody please suggest how i'd have to go about this? I've never worked with tcp/ip before.. Is this what I should use, or is there something better?
I have tried to come up with my own solution however none of the samples ever work. So I thought maybe the people on SO might know of other ways?
Thank you :)
If this is just an "in-house" (pardon the pun) application, and you're all on the same network, you might consider sending a UDP broadcast packet. Each instance of your application could listen for a packet on a particular port, and when the correct one is received do the window shake thing.
You might consider UDP for this. Since you can broadcast/multicast via UDP it may be more suitable for this sort of application. There are downsides - UDP transmission is not reliable or guaranteed in the same way as TCP.
I'd go with a good XMPP Library. Maybe Jabber-Net?
You'll also have the added bonus of being able to connect to Google Chat and now Facebook chat later.
You haven't specified if presence in your case requires a server or not. If it is client/server oriented, using XMPP gives you the server side for "free" as a bonus.

Categories

Resources