由买买提看人间百态

topics

全部话题 - 话题: socket
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
w*s
发帖数: 7227
1
// node web server
var net = require('net');
var http = require('http'),
fs = require('fs'),
// NEVER use a Sync function except at start-up!
index = fs.readFileSync(__dirname + '/socketio.html');
// Send index.html to all requests
var app = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
});
// Socket.io server listens to our app
var io = require('socket.io')(app);
//var io = require('socket.io').listen(app);
// Send ... 阅读全帖
s*****s
发帖数: 1
2
来自主题: Programming版 - Linux Socket编程
什么是Socket
Socket接口是TCP/IP网络的API,Socket接口定义了许多函数或例程,程序员可以用它们来开发TCP/IP网络上的应用程序。要学Internet上的TCP/IP网络编程,必须理解Socket接口。
Socket接口设计者最先是将接口放在Unix操作系统里面的。如果了解Unix系统的输入和输出的话,就很容易了解Socket了。网络的 Socket数据传输是一种特殊的I/O,Socket也是一种文件描述符。Socket也具有一个类似于打开文件的函数调用Socket(),该函数返回一个整型的Socket描述符,随后的连接建立、数据传输等操作都是通过该Socket实现的。常用的Socket类型有两种:流式Socket (SOCK_STREAM)和数据报式Socket(SOCK_DGRAM)。流式是一种面向连接的Socket,针对于面向连接的TCP服务应用;数据报式Socket是一种无连接的Socket,对应于无连接的UDP服务应用。
Socket建立
为了建立Socket,程序可以调用Socket函数,该函数返回一个类似于文件描述符的句柄。socket函数原型为:
l*****c
发帖数: 1153
3
来自主题: Programming版 - Linux Socket编程
原创加精,不是原创要注明出处

以用它们来开发TCP/IP网络上的应用程序。要学Internet上的TCP/IP网络编程,必须理
解Socket接口。
输入和输出的话,就很容易了解Socket了。网络的 Socket数据传输是一种特殊的I/O,
Socket也是一种文件描述符。Socket也具有一个类似于打开文件的函数调用Socket(),
该函数返回一个整型的Socket描述符,随后的连接建立、数据传输等操作都是通过该
Socket实现的。常用的Socket类型有两种:流式Socket (SOCK_STREAM)和数据报式
Socket(SOCK_DGRAM)。流式是一种面向连接的Socket,针对于面向连接的TCP服务应
用;数据报式Socket是一种无连接的Socket,对应于无连: 接的UDP服务应用。
符的句柄。socket函数原型为:
议族);type参数指定socket的类型: SOCK_STREAM 或SOCK_DGRAM,Socket接口还定
义了原始Socket(SOCK_RAW),允许程序使用低层协议;protocol通常赋值 "0"。
Socket()调用返回一
w*s
发帖数: 7227
4
Note, this is not socket.io between node server and web page client.
Instead, there's a socket between node server and c program running in the
same pc.
What i want it, every time c program send node something through the socket,
i want to publish it to the web.
No matter how i tried, cannot make it work yet, certainly my node skill is
low. Can someone help me out again ? Thank you !
The socket server in the node code is copied from
var net = require('net');
//
// Server
//
var server = new net.... 阅读全帖
w*s
发帖数: 7227
5
// node socket server simulating backend c socket server program
//
// the task is: each time this socket server sends info to node web server
// node should send to the browser
var net = require('net');
//
// Server
//
var server = new net.Server();
server.on('connection', function(socket) {
console.log('Socket is open!');
socket.setEncoding('utf8');
socket.on('data', function(data) {
var msg = "got it";
console.log('Received:', data);
socket.wri... 阅读全帖
w*s
发帖数: 7227
6





w*******y
发帖数: 60932
13
48 pc. 1/4-in. Drive Socket Module.:
http://www.sears.com/shc/s/p_10153_12605_00934270000P
Reg Price: $69.99 Now $31.49
11 6-pt. inch (5/32 thru 9/16 in.)
12 6-pt. metric (4, 5, 5.5, 6 thru 14 mm)
10 6-pt. inch deep (3/16 thru 9/16 in.)
11 6-pt. metric deep (4 thru 14 mm)
1 Thin-profile ratchet
3 Extension bars (1 1/2, 3, 6 in.)
49 pc. 3/8-in. Drive Socket Module.:
http://www.sears.com/shc/s/p_10153_12605_00934271000P?mv=rr
Reg Price: $89.99 Now $40.49
12 6-pt. in... 阅读全帖
m*********e
发帖数: 37
14
Hi guys,
When I am using the same sample from msdn, as:
____________________________________________________
// Establish the local endpoint for the socket.
IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);
// Create a TCP socket.
Socket client = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
// Connect the socket to the remote endpoint.
client.Connect(i
z***e
发帖数: 5393
15
来自主题: Programming版 - 问个socket close的问题
client<=>server
两边都执行同样的代码:
socket.Shutdown(...)
socket.Close()
sever那边没问题,但是client这边的socket就进入FIN_WAIT_2的阶段,傻等最后一个
FIN,但是那是不可能的(因为server已经close了);
这个怎么让client端的socket关掉?源代码是C#.
我现在是让server端来close socket,然后client这边再close一次,但是看起来很愚
蠢的感觉...
w*s
发帖数: 7227
16
不太一样,node server一边跟网页talk,
一边把网页的要求送到backend c++ code处理数据,这一段也是socket,就是我头痛的
地方。
所以目前想到的是node server 用socket.io_client跟c++ backend socket server
talk.
我没法反过来让node 成为server, c++ 做socket client的。
w*s
发帖数: 7227
17
good to see you come back, :)
the basic idea of call flow is like this,
1. app.listen( 3000, function(req, res) {
openSocketServer(res);
}
);
2. function openSocketServer(res) { // i added res myself
server = new net.Server();
// this is pseudo code
server.on("connection', function(socket, res) {
socket.on('data', function(data) {
res.end(data);
...
}
}
my a... 阅读全帖
w*******y
发帖数: 60932
18
This Husky 44pc socket set is in the BF ad for $19.88 in stores, but is $9.
88 online. Price mistake? Plus there's free shipping!
Here's a preview of the Husky socket set:
http://toolguyd.com/2011/10/husky-open-end-socket-set/
on ToolGuyd. For $20 I'd pass, but at $10 I might pick up one or two as
gifts.
Purchase link:
http://www.homedepot.com/webapp/wcs/stores/servlet/ProductDispl
It comes with a flex-head ratchet handle, 12 sockets, a 1/4" and 3/8" square
drive socket adapter, screwdriver bi... 阅读全帖
s****p
发帖数: 81
19
来自主题: FleaMarket版 - [出售]AMD Duron 650 MHz CPU Socket A
我想卖的物品:
AMD Duron 650 MHz CPU Socket A
CPU part number D650AST1B
Stepping codes: AKAA
Frequency (MHz) 650
Bus speed (MHz) 200
Clock multiplier 6.5
Package 453-pin staggered ceramic PGA
1.95" x 1.95" (4.95 cm x 4.95 cm)
Socket Socket A (Socket 462)
单张面值:
$1 and your mailing label.
可接受的价格 (required):
$1
物品新旧要求:
used
邮寄方式要求:
you choose you pay, my zip code is 20879
买卖双方谁承担邮寄损失(required if not code only):
default
付款方式说明:
boa or non-cc paypal
其他补充说明:
广告的有效期:
till gone
我的联系方式:
bbs
warranty期限:
p*********w
发帖数: 23432
20
来自主题: shopping版 - 请教一个机械上的 socket 的型号
SOCKET 1. 1/2" DRIVE SIZE 2. 1/2 INCH
SOCKET 1. 1/2" DRIVE SIZE 2. 3/8 INCH
SOCKET 1. 1/2" DRIVE SIZE 2. 1/4 INCH
朋友说帮忙看看这几个东西
我搜索了一下,好像 socket 都是 1/2" drive,没有 1.1/2" 的
不知道应该到哪里找这些东西
a***a
发帖数: 161
21
来自主题: Java版 - java socket 问题
利用socket发送数据, 直接调用 socket.send()
和利用 socket.getOutputStream().write()
哪个好些?
我原来一直用socket直接发送, 后来看到有些
比较专业的程序用后者, 就疑惑了.
谢谢!
c*******t
发帖数: 32
22
I need transfer data between two sockets. After create two sockets,
I use the below code to transfer data. When I type the first line,
I got the response line from another socket. But when I type one more
line, the another socket cannot get this line. Could somebody help me?
while ( (numBytesClient = fromClient.read(bufferClient)) != -1) {
toAnotherClient.write(bufferClient,0,numBytesClient);
toAnotherClient.flush();
}
while ((numBytesAnotherClient = fromAnotherClient.read(bufferAnother))
D*********s
发帖数: 555
23
来自主题: Java版 - 有人用过异步Socket么?
Where did you get the data saying that NB Socket's performance
is bad? any link please.
You said I can use non-blocking socket along with Stream. Can you
please tell some details?
As I know if you don't use nio, which has select(), you actually
can't use non-blocking socket because busy waiting is a BAD idea.
Did you just refer to this busy waiting when you said NB socket's
performance?
e******d
发帖数: 14
24
来自主题: Programming版 - question about socket programming
一个线程已经在阻塞的select一组socket,同时SERVER又产生了一个新的socket,怎么
把这个新的socket加到这一组socket中,一起听。
S*A
发帖数: 7142
25
来自主题: Programming版 - C10M 练习 step 1: 10M sockets
我觉得大家讨论很热情,
我们来做点练习吧,不要光说不练。
下面这个程序是暴露一些写 C10M 可能碰到的问题,
看看大家有没有神魔解决方法。如果有,请贴程序或者
脚本,方便他人重复实验.
如果实在没有人贴答案,我也可以公布我自己的。
#include
#include
#include
#include
int main(int argc, char *argv[])
{
int i;
for (i = 0; i < 1024*1024*10; i++) {
int s;
s = socket(PF_INET, SOCK_STREAM, 0);
if (s < 0) {
char buffer[1024];
snprintf(buffer, sizeof buffer, "socket #%d", i);
perror(buffer);
... 阅读全帖
w*s
发帖数: 7227
26
如果socket server restart,
node socket client可以reconnect吗 ?
socket.io可以reconnect的。
w*s
发帖数: 7227
27
i'm posting my code here,
1st is the socket server, sends data to 2nd node web server,
node web server sends data to browser using socket.io.
this is barely working.
but my question is,
how to do it without socket.io.
hang on, posting code now
the last code, i have the question
socket.on('data', function(data) {
console.log('Received:', data);
// question ???
//res.end(data); //how to make this line to work without using io.
emit
// also why output in browser... 阅读全帖
w*s
发帖数: 7227
28
来自主题: Programming版 - Nodejs socket.io emit看不懂
var app = require('express').createServer();
var io = require('socket.io')(app);
app.listen(80);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});
这个emit里'news'相当于tag这我知道。
后边那hello world为哈要写成那样?
w*******y
发帖数: 60932
29
Sears have a "Lowest Price Ever" sale on some Craftsman Items
Select pick up in store to save on shipping
Use Code SDEALS817 for $5 off $50 to sweeten the deal if you mix and match
Craftsman 2-1/4 ton Floor Jack Set with 2-1/4 ton Jack Stands:
http://www.sears.com/shc/s/p_10153_12605_00950140000P?prdNo=2
- $37.04
Previous Front Page Deal on the Jack above at $37.99 for reference
Craftsman 10 pc., 6 pt. 3/8 in. Dr. Standard Socket Wrench Set:
http://www.sears.com/shc/s/p_10153_12605_00934553000... 阅读全帖
r*********s
发帖数: 2157
30
【 以下文字转载自 Auto_Fans 俱乐部 】
发信人: redlobsters (Don't piss me off), 信区: Auto_Fans
标 题: Stanley的这套sockets (tool set)怎么样?
发信站: BBS 未名空间站 (Thu Sep 1 18:29:10 2011, 美东)
不知道Stanley sockets的质量如何?今天在costco看到下面这套 149 pieces的卖$69
。 我用过stanley的其他一些手动工具比如凿子什么的, 质量还不错。
我已经有1/4 和 3/8 的 sockets了, 一直想买套 1/2的。 买下面这个有些重复的,
但是从其他地方只买1/2的价格也不便宜。
http://www.stanleytools.com/default.asp?CATEGORY=SMT+MECH+SETS&
s****i
发帖数: 5469
31
来自主题: Automobile版 - 这个Socket Set怎么样?
在advanceautoparts、autozone等网站有socket set,可以这么选:首先了解螺丝
的信息,英制公制、尺寸范围等,换刹车片也算常见的DIY了,在你相应车的英文论坛
上应该能找到。另外,看另一端的口径,有1/4,3/8和1/2 drive可选,口径越大能承
受的力越大。3/8是比较常见的,一般延长一下力臂(用长扳手或套个管)就够用,但
个别紧的螺丝(车轮,还有你可能要遇到的生锈的caliper)推荐用1/2。有些螺丝需要
deep socket,也成套卖。如果能用六角的,就不要用十二点的,后者容易拧花。如果
正好缺某个尺寸,再单独买。
个人建议有条件的话3/8和1/2的都备一套,根据情况来,反正你DIY一次省的钱足够
买很多工具了。当然,还有一个办法是买套转换接头。ratchet这东西如果有和socket
set成套的就一起买,没有的话就单买。breaker bar建议也备一个,能对付不少螺丝。
a****o
发帖数: 133
32
来自主题: Automobile版 - 换spark plug到底需要什么socket?
只看见有卖盒装的socket set 就是一盒一套十几个个的socket
还需要spark plug专用的某种socket吗?
还有看网上视频还有什么extension、racket是啥意思?
有无高人详细说一下一共需要哪些工具才够用呢?谢谢
g********b
发帖数: 8461
33
可以。impact socket比普通socket更结实更好,完全可以代替普通socket。
a*p
发帖数: 62
34
【 以下文字转载自 Java 讨论区,原文如下 】
发信人: atp (BigMouse), 信区: Java
标 题: Re: 救命,IE,Socket,安全性
发信站: The unknown SPACE (Sat Mar 17 18:09:27 2001) WWW-POST
我也是这么想的,但是这样的一个现象没有办法解释啊:
我自己的机器有web服务器,
我用http://localhost/Chat.html(IE会在下面显示Intranet)
调用=new Socket(...)的时候有SecurityException错误
但是如果用我自己的域名http://myhostname/Chat.html(IE会在下面
显示Internet)
就不会出SecurityException,程序运行很正常
我检查了,IE里面显然Intranet得安全性要低于Internet的。
还有MacOS的现象怎么解释?
哪位大虾编过applet+socket的程序成功过?指教啊。
我是菜鸟
o******t
发帖数: 1144
35
Any experience on it?
For example, the ObjectOutputStream oos get from a java socket, you can call
oos.reset() fine if both side are in Linux, but in Windows, if remote side
call oos.reset(), socket Windows will through socket reset exception.
b******e
发帖数: 671
36
来自主题: Java版 - A Simple Java Socket Issue
Thanks a lot. It helps.
Now, I can see from NETSTAT that the port 80 of IP 192.168.0.100 is
Listening.
When I try to open a client socket to connect with server, such as
Socket sock = new Socket("192.168.0.100", 80);
It throws a "connection refuse" exception. Any suggestion?
By the way, I turned off the XP firewall.
mw
发帖数: 525
37
来自主题: Programming版 - socket re-connection problem
Now i have a TCP/IP, server program. It uses its ip address and port number to
bind a socket ,then listen and connect.
The problem is , after the client side is shutdown, it needs to re-connect.
But after I "closesocket", how can i re-setup this connection ?
My process is "open socket again" ->setsockopt->bind, but the "bind" just
fails and complains that the port is in use. Wierd! I have already shutdown
the socket use "closesocket", there should not be such problem at all...
can anyone help?
t
c********e
发帖数: 383
38
来自主题: Programming版 - socket re-connection problem
dont quite understand what you said ....but if you are binding the client
program who is doing the connect call, 1. you dont have to you can use the
em..port that the kernal gives you. INET_ANY 2, there is a socket option to
make the socket reusable check man page for setsockopt. this is usually for
sockets in the waiting state.
c***d
发帖数: 996
39
来自主题: Programming版 - [合集] 问个SOCKET问题啊 (转载)
☆─────────────────────────────────────☆
dongxie (我翻我翻我翻翻翻) 于 (Thu Jun 14 11:16:00 2007) 提到:
发信人: dongxie (我翻我翻我翻翻翻), 信区: NewJersey
标 题: 问个SOCKET问题啊
发信站: BBS 未名空间站 (Thu Jun 14 11:05:10 2007), 转信
connection oriented socket,
use accept, return > 0 valid fd
但是if want to write to that fd, will fail by bad file descripter.
any idea?
☆─────────────────────────────────────☆
observer (笑看人生) 于 (Thu Jun 14 11:18:56 2007) 提到:
Are U WRITING to a socket fd?

☆─────────────────────────────────────☆
w*s
发帖数: 7227
40
兄弟,我要的是同时socket client用node.js, socket server用c++
抱歉我说话不利索,今年股票又亏了,正在郁闷中。
w*s
发帖数: 7227
41
就举这个例子,
https://delog.wordpress.com/2012/05/11/socket-io-node-js-client-to-server/
client
conn.emit('call', p1, function(resp, data)
server 那边
socket.on('call', function (p1, fn) {
注意call是一个tag,2边要一致。
如果server是c++怎么做这个 on('call') ?
z****e
发帖数: 54598
42

你不是要简单的tcp就好了嘛?
简单的tcp的c socket用上面那个
node socket用这个
https://gist.github.com/tedmiston/5935757
l**********n
发帖数: 8443
43
来自主题: Programming版 - Nodejs socket.io emit看不懂
我替你查了
Socket#emit(name:String[, …]):Socket
Emits an event to the socket identified by the string name. Any
other parameters can be included.
All datastructures are supported, including Buffer. JavaScript
functions can’t be serialized/deserialized.
a****s
发帖数: 47
44
来自主题: Unix版 - [转载] socket 急救
【 以下文字转载自 Programming 讨论区 】
【 原文由 abatis 所发表 】
我用setsockopt并代参SO_BROADCAST将socket 设为broadcast socket,
now I want to change this socket back to normal, what parameter
should I use in setsockopt? thanks a lot.
c***i
发帖数: 188
45
来自主题: Unix版 - a socket question
if i close 1 binded socket and immediately open it and rebind it.
if the socket still have data to send when being closed , i can not
rebind it immediately, i 've set the option SO_REUSEADDR but still
fail.
what's the best way to deal with such things, this happens when ur
server crashed and u want to restart it immiediately, right now
i just wait for the bind to succeed, but usually it will take about
1+ min.
PS: seems linux (redhat 6.2) do not support SO_REUSEPORT, and i'm using
TCP socket.
th
os
发帖数: 81
46
来自主题: Unix版 - [转载] BSD Sockets Programming ...
【 以下文字转载自 Programming 讨论区 】
【 原文由 os 所发表 】
Posted from LISF
Download Address: http://www.lanken.com/forum/viewtopic.php?t=53
BSD Sockets Programming from a Multi-Language Perspective.
ISBN: 1-58450-268-1, Charles River Media, October 2003.
444 Pages, Paperback.
BSD Sockets Programming from a Multi-Language Perspective is
written for software deve-lopers who need to create a variety of
network applications. It begins by detailing the efficient and
effective uses of the BSD Sockets API for net
b*********n
发帖数: 1258
47
【 以下文字转载自 Hardware 讨论区 】
发信人: babyfacenan (baby_face), 信区: Hardware
标 题: CPU是不是socket match就可以升级了?
发信站: BBS 未名空间站 (Sun Dec 18 22:06:32 2005), 站内
发信人: babyfacenan (baby_face), 信区: shopping
标 题: CPU是不是socket match就可以升级了?
发信站: BBS 未名空间站 (Sun Dec 18 22:06:24 2005), 转信
现在的是amd athlon xp 1800+
是不是找一个socket A的cpu就可以升级现在的cpu了
主板什么的就不用换了
现在的cpu坏了
谢谢
l****n
发帖数: 723
48
来自主题: _Auto_Fans版 - 大家说说用的什么sockets吧
一套 craftmman最小的那种,后来在HF买了一套impact socket和deep wall impact
socket,以及一个1/2的ratchet,感觉很划算。 尤其是那个ratchet感觉比craftsman
好得多。使用频率很高,现在买了goodyear的impact gun,也不用重复买socket了。
s*****b
发帖数: 4115
49
Update:
最好打电话问问ACE有没有货,ACE socket选择很少,而且Craftsman是Ace的新货,我
去的一家店根本没有任何Craftsman的东西
很简单的3/8寸套装,没有任何转接头,比sears便宜10~15块,In Store Only。
我本来打算买Sears 51pc的那套工具(看起来像样点),网上$60,但既然Ace这么便宜
,就先买便宜的用着吧,说不定一年之后就要送人了。
对了,据说pass through的很少有deal
http://www.acehardware.com/family/index.jsp?categoryId=4339735&
Pass Through sockets和Deep Wall Sockets各有各的好处。Deep Wall好处是可以上
breaker bar,但不能用在狭窄的地方;Pass Through不能上breaker bar(套水管力矩
太大时可能会损坏ratchet),但能用的地方更多
w*******y
发帖数: 60932
50
1-to-3 Cigarette Socket Power Splitter with USB Charge Port $2 shipped ac
1-to-3 Cigarette Socket Power Splitter with USB Charge Port
Link:
http://www.meritline.com/1-to-3-cigarrete-socket-power-splitter---p-27269.aspx?source=nl100816
1.99 w/Coupon Code: MLCK401029081651NL1 For First 1000 Orders
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)