I'm currently in the process of developing a client/server chat with the client written in C#, and the server in PHP.
I'm interested in using TCP sockets to realise this chat program. I know what should the client look like, since I made several client/server chat applications (but both the server and the client were written in C#).
The problem I'm having is really that I'm stumped what the PHP should look like. I've really searched the internet for some C#/PHP chat, when I saw that there were none (or I just couldn't find anything), I started looking for Java/PHP and C++/PHP chat applications, since it does not present a problem to me to port applications from java or c++ to C#, unfortunately I couldn't find none. Next I tried just to look for C# PHP communication but still I find nothing.
I'm really stumped on what should the PHP look like, and I've really tried to find some documentation on that, but the search yield no results.
I have a really good background in desktop development and in general programming paradigms and principles, and some intermediate experience in PHP.
So if anyone could help or point to the correct literature I would be really grateful.
PHP (Server) + C# (Client) Chat
Page 1 of 15 Replies - 939 Views - Last Post: 14 July 2012 - 11:50 AM
Replies To: PHP (Server) + C# (Client) Chat
#2
Re: PHP (Server) + C# (Client) Chat
Posted 13 July 2012 - 05:28 PM
PHP has Socket functions you can use, and there is an example in the docs of PHP client-server code using those. Of course, it shows the client as PHP code, but it can just as well be C# on the other end.
I would also point out that PHP is not exactly an ideal language for a server like this. You'd usually want to be able to use threading for that, which is not something PHP can do.
I would also point out that PHP is not exactly an ideal language for a server like this. You'd usually want to be able to use threading for that, which is not something PHP can do.
#4
Re: PHP (Server) + C# (Client) Chat
Posted 14 July 2012 - 08:01 AM
Honestly, I wouldn't recommend it. For one, it doesn't support threads either. It was designed to work in single nodes; one separate, concurrent node instance for each "thread" you want running. Not ideal for this kind of work either.
I've used it myself recently and, even though it's an interesting concept to use Javascript on the server, the code tends to get a bit annoying. Pretty much everything is asynchronous, so it uses callback functions all over the place. It's not uncommon to see things like:
Either that or:
I'm not entirely sure which one is more annoying. Of course, this is just my personal opinion. The language works fine so if this doesn't bother you, it may be worth a try.
I would rather consider something like Python instead though. It's got threads, it's syntax is generally awesome, and it tends to be installed and ready on PHP servers.
I've used it myself recently and, even though it's an interesting concept to use Javascript on the server, the code tends to get a bit annoying. Pretty much everything is asynchronous, so it uses callback functions all over the place. It's not uncommon to see things like:
doStuff(function(callback) {
doSomeMoreStuff(function(e) {
if (e) {
callback(e, null);
} else {
continueDoingStuff(function(e) {
if (e) {
callback(e, null);
} else {
andDoOneFinalThing(function(e, data) {
if (e) {
callback(e, null);
} else {
callback(null, data);
}
});
}
});
}
});
});
Either that or:
doStuff(function(callback) {
var doSomeMoreStuffCallback = function(e) {
if (e) {
callback(e, null);
} else {
continueDoingStuff(continueDoingStuffCallback);
}
}
var continueDoingStuffCallback = function(e) {
if (e) {
callback(e, null);
} else {
andDoOneFinalThing(andDoOneFinalThingCallback);
}
}
var andDoOneFinalThingCallback = function(e) {
if (e) {
callback(e, null);
} else {
callback(null, data);
}
}
doSomeMoreStuff(doSomeMoreStuffCallback);
});
I'm not entirely sure which one is more annoying. Of course, this is just my personal opinion. The language works fine so if this doesn't bother you, it may be worth a try.
I would rather consider something like Python instead though. It's got threads, it's syntax is generally awesome, and it tends to be installed and ready on PHP servers.
#5
Re: PHP (Server) + C# (Client) Chat
Posted 14 July 2012 - 09:24 AM
Oh man, that is ugly. I just heard a lot about Node.js as a server; thought it might be well-suited to this. Python would be a good choice, maybe fronting a message queue (something AMQP-based, perhaps).
#6
Re: PHP (Server) + C# (Client) Chat
Posted 14 July 2012 - 11:50 AM
I'm going to try to make the server using PHP, even though it's not ideal. I'll also try to do it in python (I just have no experience with the language what so ever)... Thanks for the feedback! 
Oh and I've tried Node.js, you have to actually make the whole server from scratch, you have to make your own server, router, routeHandlers, it's like all the other languages but instead of further simplifying things it forces you to do all the boring stuff that is automated in other languages. (What a bummer
) I guess it's good for something but for general use, I think I'll still stick to what I've been doing.
Oh and I've tried Node.js, you have to actually make the whole server from scratch, you have to make your own server, router, routeHandlers, it's like all the other languages but instead of further simplifying things it forces you to do all the boring stuff that is automated in other languages. (What a bummer
This post has been edited by RexGrammer: 14 July 2012 - 11:51 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote






|