@@ -11,22 +11,8 @@ use libc::size_t;
11
11
use io:: { Reader , ReaderUtil , Writer } ;
12
12
use comm = core:: comm;
13
13
14
- // tcp interfaces
15
- export TcpSocket ;
16
- // buffered socket
17
- export TcpSocketBuf , socket_buf;
18
- // errors
19
- export TcpErrData , TcpConnectErrData ;
20
- // operations on a tcp_socket
21
- export write, write_future, read_start, read_stop;
22
- // tcp server stuff
23
- export listen, accept;
24
- // tcp client stuff
25
- export connect;
26
-
27
14
#[ nolink]
28
15
extern mod rustrt {
29
- #[ legacy_exports] ;
30
16
fn rust_uv_current_kernel_malloc ( size : libc:: c_uint ) -> * libc:: c_void ;
31
17
fn rust_uv_current_kernel_free ( mem : * libc:: c_void ) ;
32
18
fn rust_uv_helper_uv_tcp_t_size ( ) -> libc:: c_uint ;
@@ -48,7 +34,7 @@ struct TcpSocket {
48
34
}
49
35
}
50
36
51
- fn TcpSocket ( socket_data : @TcpSocketData ) -> TcpSocket {
37
+ pub fn TcpSocket ( socket_data : @TcpSocketData ) -> TcpSocket {
52
38
TcpSocket {
53
39
socket_data : socket_data
54
40
}
@@ -64,14 +50,14 @@ struct TcpSocketBuf {
64
50
data : @TcpBufferedSocketData ,
65
51
}
66
52
67
- fn TcpSocketBuf ( data : @TcpBufferedSocketData ) -> TcpSocketBuf {
53
+ pub fn TcpSocketBuf ( data : @TcpBufferedSocketData ) -> TcpSocketBuf {
68
54
TcpSocketBuf {
69
55
data : data
70
56
}
71
57
}
72
58
73
59
/// Contains raw, string-based, error information returned from libuv
74
- type TcpErrData = {
60
+ pub type TcpErrData = {
75
61
err_name : ~str ,
76
62
err_msg : ~str
77
63
} ;
@@ -103,7 +89,7 @@ enum TcpListenErrData {
103
89
AccessDenied
104
90
}
105
91
/// Details returned as part of a `result::err` result from `tcp::connect`
106
- enum TcpConnectErrData {
92
+ pub enum TcpConnectErrData {
107
93
/**
108
94
* Some unplanned-for error. The first and second fields correspond
109
95
* to libuv's `err_name` and `err_msg` fields, respectively.
@@ -129,7 +115,7 @@ enum TcpConnectErrData {
129
115
* the remote host. In the event of failure, a
130
116
* `net::tcp::tcp_connect_err_data` instance will be returned
131
117
*/
132
- fn connect ( input_ip : ip:: IpAddr , port : uint ,
118
+ pub fn connect ( input_ip : ip:: IpAddr , port : uint ,
133
119
iotask : IoTask )
134
120
-> result:: Result < TcpSocket , TcpConnectErrData > unsafe {
135
121
let result_po = core:: comm:: Port :: < ConnAttempt > ( ) ;
@@ -262,7 +248,7 @@ fn connect(input_ip: ip::IpAddr, port: uint,
262
248
* A `result` object with a `nil` value as the `ok` variant, or a
263
249
* `tcp_err_data` value as the `err` variant
264
250
*/
265
- fn write( sock: & TcpSocket , raw_write_data: ~[ u8] )
251
+ pub fn write( sock: & TcpSocket , raw_write_data: ~[ u8] )
266
252
-> result:: Result <( ) , TcpErrData > unsafe {
267
253
let socket_data_ptr = ptr:: addr_of ( & ( * ( sock. socket_data ) ) ) ;
268
254
write_common_impl ( socket_data_ptr, raw_write_data)
@@ -299,7 +285,7 @@ fn write(sock: &TcpSocket, raw_write_data: ~[u8])
299
285
* `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data`
300
286
* value as the `err` variant
301
287
*/
302
- fn write_future( sock: & TcpSocket , raw_write_data: ~[ u8] )
288
+ pub fn write_future( sock: & TcpSocket , raw_write_data: ~[ u8] )
303
289
-> future:: Future <result:: Result <( ) , TcpErrData >> unsafe {
304
290
let socket_data_ptr = ptr:: addr_of ( & ( * ( sock. socket_data ) ) ) ;
305
291
do future_spawn {
@@ -323,7 +309,7 @@ fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
323
309
* optionally, loop on) from until `read_stop` is called, or a
324
310
* `tcp_err_data` record
325
311
*/
326
- fn read_start ( sock : & TcpSocket )
312
+ pub fn read_start ( sock : & TcpSocket )
327
313
-> result:: Result < comm:: Port <
328
314
result:: Result < ~[ u8 ] , TcpErrData > > , TcpErrData > unsafe {
329
315
let socket_data = ptr:: addr_of ( & ( * ( sock. socket_data ) ) ) ;
@@ -337,7 +323,7 @@ fn read_start(sock: &TcpSocket)
337
323
*
338
324
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
339
325
*/
340
- fn read_stop ( sock : & TcpSocket ,
326
+ pub fn read_stop ( sock : & TcpSocket ,
341
327
+read_port : comm:: Port < result:: Result < ~[ u8 ] , TcpErrData > > ) ->
342
328
result:: Result < ( ) , TcpErrData > unsafe {
343
329
log ( debug, fmt ! ( "taking the read_port out of commission %?" , read_port) ) ;
@@ -472,7 +458,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
472
458
* this function will return a `net::tcp::tcp_err_data` record
473
459
* as the `err` variant of a `result`.
474
460
*/
475
- fn accept ( new_conn : TcpNewConnection )
461
+ pub fn accept ( new_conn : TcpNewConnection )
476
462
-> result:: Result < TcpSocket , TcpErrData > unsafe {
477
463
478
464
match new_conn{
@@ -570,7 +556,7 @@ fn accept(new_conn: TcpNewConnection)
570
556
* successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
571
557
* of listen exiting because of an error
572
558
*/
573
- fn listen ( host_ip : ip:: IpAddr , port : uint , backlog : uint ,
559
+ pub fn listen ( host_ip : ip:: IpAddr , port : uint , backlog : uint ,
574
560
iotask : IoTask ,
575
561
+on_establish_cb : fn ~( comm:: Chan < Option < TcpErrData > > ) ,
576
562
+new_connect_cb : fn ~( TcpNewConnection ,
@@ -728,17 +714,17 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
728
714
*
729
715
* A buffered wrapper that you can cast as an `io::reader` or `io::writer`
730
716
*/
731
- fn socket_buf ( sock : TcpSocket ) -> TcpSocketBuf {
717
+ pub fn socket_buf ( sock : TcpSocket ) -> TcpSocketBuf {
732
718
TcpSocketBuf ( @{ sock: move sock, mut buf: ~[ ] } )
733
719
}
734
720
735
721
/// Convenience methods extending `net::tcp::tcp_socket`
736
722
impl TcpSocket {
737
- fn read_start ( ) -> result:: Result < comm:: Port <
723
+ pub fn read_start ( ) -> result:: Result < comm:: Port <
738
724
result:: Result < ~[ u8 ] , TcpErrData > > , TcpErrData > {
739
725
read_start ( & self )
740
726
}
741
- fn read_stop ( read_port :
727
+ pub fn read_stop ( read_port :
742
728
comm:: Port < result:: Result < ~[ u8 ] , TcpErrData > > ) ->
743
729
result:: Result < ( ) , TcpErrData > {
744
730
read_stop ( & self , move read_port)
@@ -751,11 +737,11 @@ impl TcpSocket {
751
737
future:: Future < result:: Result < ~[ u8 ] , TcpErrData > > {
752
738
read_future ( & self , timeout_msecs)
753
739
}
754
- fn write ( raw_write_data : ~[ u8 ] )
740
+ pub fn write ( raw_write_data : ~[ u8 ] )
755
741
-> result:: Result < ( ) , TcpErrData > {
756
742
write ( & self , raw_write_data)
757
743
}
758
- fn write_future ( raw_write_data : ~[ u8 ] )
744
+ pub fn write_future ( raw_write_data : ~[ u8 ] )
759
745
-> future:: Future < result:: Result < ( ) , TcpErrData > > {
760
746
write_future ( & self , raw_write_data)
761
747
}
@@ -816,7 +802,7 @@ impl TcpSocketBuf: io::Reader {
816
802
817
803
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
818
804
impl TcpSocketBuf : io:: Writer {
819
- fn write ( data : & [ const u8 ] ) unsafe {
805
+ pub fn write ( data : & [ const u8 ] ) unsafe {
820
806
let socket_data_ptr =
821
807
ptr:: addr_of ( & ( * ( ( * ( self . data ) ) . sock ) . socket_data ) ) ;
822
808
let w_result = write_common_impl ( socket_data_ptr,
@@ -1224,16 +1210,13 @@ type TcpBufferedSocketData = {
1224
1210
1225
1211
//#[cfg(test)]
1226
1212
mod test {
1227
- #[ legacy_exports] ;
1228
1213
// FIXME don't run on fbsd or linux 32 bit (#2064)
1229
1214
#[ cfg( target_os="win32" ) ]
1230
1215
#[ cfg( target_os="darwin" ) ]
1231
1216
#[ cfg( target_os="linux" ) ]
1232
1217
mod tcp_ipv4_server_and_client_test {
1233
- #[ legacy_exports] ;
1234
1218
#[ cfg( target_arch="x86_64" ) ]
1235
1219
mod impl64 {
1236
- #[ legacy_exports] ;
1237
1220
#[ test]
1238
1221
fn test_gl_tcp_server_and_client_ipv4 ( ) unsafe {
1239
1222
impl_gl_tcp_ipv4_server_and_client ( ) ;
@@ -1258,7 +1241,6 @@ mod test {
1258
1241
}
1259
1242
#[ cfg( target_arch="x86" ) ]
1260
1243
mod impl32 {
1261
- #[ legacy_exports] ;
1262
1244
#[ test]
1263
1245
#[ ignore( cfg( target_os = "linux" ) ) ]
1264
1246
fn test_gl_tcp_server_and_client_ipv4 ( ) unsafe {
0 commit comments