![]() |
|
[.NET] PHP Chat changing to socket chat, if possible. Help me please - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] PHP Chat changing to socket chat, if possible. Help me please (/showthread.php?tid=5155246) Pages: Pages
1
2
|
PHP Chat changing to socket chat, if possible. Help me please - Flzduden - Feb 1, 2016 Hello fellow .NET programmers. So i'm currently working on a chat, like Skype and i got it working! But since it's using PHP and it is making requests to my website each second it's a bit laggy. Then i used threads, and it certainly helped a lot, but just not enough. So earlier today i read about sockets, and if i understood it correctly i should be able to create a server, and of course a client that listens for new chat strings? How am i gonna do this? I hope that some of you guys can help me in the right direction. Of course i'm not looking for source code ready for CP. I'm here for learning! * - +Haze - Feb 1, 2016 A Php chat is highly inefficient on your server since you're querying it every second, yes you should use sockets and not a web request since that's bad server side. What you should do is setup the server as the server all the clients connect to. * - Flzduden - Feb 1, 2016 It's a vb.net application that makes request to my mysql through php. I dont care about security right now either. I wanna know how it's working, before i go into security. It should be client -> server -> client * - +Haze - Feb 1, 2016 (Feb 1, 2016 11:13 AM)Flzduden ツ Wrote: It's a vb.net application that makes request to my mysql through php. I dont care about security right now either. I wanna know how it's working, before i go into security. Well if that's what you're looking for then I made this some time ago, https://hackforums.net/showthread.php?tid=4615781 Though I wouldn't recommend it, I'd recommend using sockets, but I guess it's good for learning purposes. * - Flzduden - Feb 1, 2016 (Feb 1, 2016 11:16 AM)+Haze Wrote: Well if that's what you're looking for then I made this some time ago, Yeah sockets is exactly what i'm trying to learn, i got totally misunderstood (probably my shitty english lol) I already HAVE made a php chat, but it's quite unstable. * - Ninja - Feb 2, 2016 Code Private Sub formMain_Load(sender As Object, e As EventArgs) Handles MyBase.LoadSome code I had laying around. This should give you the general idea. * - +Haze - Feb 2, 2016 (Feb 2, 2016 09:52 AM)Tyranitar Wrote: Why are you catching an Exception only to ignore it? Tut tut tut * - Odus - Feb 2, 2016 (Feb 2, 2016 09:52 AM)Tyranitar Wrote: :( You're also mixing between sync and async in that snippet. * - Remix - Feb 2, 2016 (Feb 1, 2016 11:16 AM)+Haze Wrote: Well if that's what you're looking for then I made this some time ago, You have some PHP errors in the scripts 😠 Well they're more logical mistakes * - +Haze - Feb 2, 2016 I wrote that code literally last year ago, even I don;t recommend that code. * - Flzduden - Feb 2, 2016 Thanks for all the inputs. I found a few tutorials on the www, but i just dont get it really. All of those tut's can only send data one way. Like from the client to the server, or from the server to multiple clients. The client shouldn't act as a server in any way right? Cuz then all of those clients would have to port forward, and that's not the idea really.. Only the server host should portforward. Am i right on this? * - Odus - Feb 2, 2016 (Feb 2, 2016 03:34 PM)Flzduden ツ Wrote: Thanks for all the inputs. I found a few tutorials on the www, but i just dont get it really. All of those tut's can only send data one way. Like from the client to the server, or from the server to multiple clients. The client shouldn't act as a server in any way right? Cuz then all of those clients would have to port forward, and that's not the idea really.. Only the server host should portforward. Am i right on this? Think of it as reverse connection, just like with rats. It's still possible to communicate data between the client and server. * - Flzduden - Feb 2, 2016 (Feb 2, 2016 03:37 PM)Odus Wrote: Think of it as reverse connection, the end users connect to you, just like with rats. It's still possible to communicate data between the client and server. wow, didn't think of it that way. I think i'm in the right direction now, i got i sending from client to server - and from server to client now. That's kinda what i would acheive from it. So thanks to everyone helping. Such a great forum. * - Ninja - Feb 2, 2016 (Feb 2, 2016 12:44 PM)+Haze Wrote: Why are you catching an Exception only to ignore it? Tut tut tut its just something I wrote quick to test sockets. (Feb 2, 2016 01:17 PM)Odus Wrote: :( See previous post. * - deiski - Feb 3, 2016 (Feb 2, 2016 09:52 AM)Tyranitar Wrote: At least know what you're doing before you start giving other people bad habits. |