return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>html javascript connect to raw socket - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html javascript connect to raw socket - Stack Overflow

programmeradmin3浏览0评论

I have a c# tcp server, I want to connect to the server via a html client page.

The problem: There is no simple way to create TCP sockets in Javascript on a browser side. Although solutions like Websockets allow to create something that resemble sockets, you can use them to connect only to servers that support Websockets. Not to any random servers that know nothing about HTTP.

so is there a solution to connect to my srver.

I have a c# tcp server, I want to connect to the server via a html client page.

The problem: There is no simple way to create TCP sockets in Javascript on a browser side. Although solutions like Websockets allow to create something that resemble sockets, you can use them to connect only to servers that support Websockets. Not to any random servers that know nothing about HTTP.

so is there a solution to connect to my srver.

Share Improve this question asked Oct 30, 2015 at 17:10 Med BesbesMed Besbes 2,0216 gold badges25 silver badges37 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

No. There just isn't. The browser is a tightly locked down environment. The only socket connection that you can open from JavaScript is WebSocket. Since it's your server, adding WebSocket support shouldn't be too plicated, and there are WebSocket libraries available for C#.

Maybe someone else will have an idea for you, but...

The best solution I can think of is for your server to support websockets.

The situation you described - along with connectivity issues for traffic passing through proxies and routers - is one of the reasons Websockets were introduced in the first place.

Bare in mind that Websockets can send and receive binary data. It's just that javascript make it more fortable to write text based messages.

Also, many NAT routers, Proxies and firewalls will block raw TCP/IP munication while allowing Http munication to pass through. This is why you have a better chance at connection establishment and retention when implementing the Websocket protocol.

I know I'm very late to this but, try creating a WebSocket "proxy".

Create a WebSocket server that connects to your raw socket server and passes on the data given to the WebSocket.

Hope this helps!

发布评论

评论列表(0)

  1. 暂无评论