Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LARN
PRRT
Commits
bda79245
Commit
bda79245
authored
Apr 26, 2018
by
Andreas Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PrrtSocket gets address tuple as first parameter.
parent
e2fbdea1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
5 deletions
+7
-5
examples/receiver.py
examples/receiver.py
+1
-1
examples/sender.py
examples/sender.py
+1
-1
prrt/proto/socket.c
prrt/proto/socket.c
+2
-0
prrt/prrt.pyx
prrt/prrt.pyx
+3
-3
No files found.
examples/receiver.py
View file @
bda79245
...
@@ -3,7 +3,7 @@ import prrt
...
@@ -3,7 +3,7 @@ import prrt
port
=
int
(
sys
.
argv
[
1
])
port
=
int
(
sys
.
argv
[
1
])
s
=
prrt
.
PrrtSocket
(
port
=
port
)
s
=
prrt
.
PrrtSocket
(
(
"127.0.0.1"
,
port
)
)
while
True
:
while
True
:
d
,
addr
=
s
.
recv
()
d
,
addr
=
s
.
recv
()
...
...
examples/sender.py
View file @
bda79245
...
@@ -5,7 +5,7 @@ host = sys.argv[1]
...
@@ -5,7 +5,7 @@ host = sys.argv[1]
port
=
int
(
sys
.
argv
[
2
])
port
=
int
(
sys
.
argv
[
2
])
localport
=
int
(
sys
.
argv
[
3
])
localport
=
int
(
sys
.
argv
[
3
])
s
=
prrt
.
PrrtSocket
(
port
=
localport
)
s
=
prrt
.
PrrtSocket
(
(
"127.0.1.1"
,
localport
)
)
s
.
connect
(
host
,
port
)
s
.
connect
(
host
,
port
)
for
i
in
range
(
10
):
for
i
in
range
(
10
):
...
...
prrt/proto/socket.c
View file @
bda79245
...
@@ -136,6 +136,8 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
...
@@ -136,6 +136,8 @@ bool PrrtSocket_bind(PrrtSocket *s, const char *ipAddress, const uint16_t port)
struct
sockaddr_in
*
address
=
calloc
(
1
,
size
);
struct
sockaddr_in
*
address
=
calloc
(
1
,
size
);
check_mem
(
address
);
check_mem
(
address
);
// TODO: Allow DNS names to be passed as ipAddress.
address
->
sin_family
=
AF_INET
;
address
->
sin_family
=
AF_INET
;
address
->
sin_addr
.
s_addr
=
inet_addr
(
ipAddress
);
address
->
sin_addr
.
s_addr
=
inet_addr
(
ipAddress
);
address
->
sin_port
=
htons
((
uint16_t
)
(
port
));
address
->
sin_port
=
htons
((
uint16_t
)
(
port
));
...
...
prrt/prrt.pyx
View file @
bda79245
...
@@ -118,13 +118,13 @@ class PrrtCodingConfiguration:
...
@@ -118,13 +118,13 @@ class PrrtCodingConfiguration:
cdef
class
PrrtSocket
:
cdef
class
PrrtSocket
:
cdef
cprrt
.
PrrtSocket
*
_c_socket
cdef
cprrt
.
PrrtSocket
*
_c_socket
def
__cinit__
(
self
,
port
,
target_delay
=
1
,
thread_pinning
=
False
):
def
__cinit__
(
self
,
address
,
target_delay
=
1
,
thread_pinning
=
False
):
host
,
port
=
address
target_delay_us
=
target_delay
*
1000
**
2
target_delay_us
=
target_delay
*
1000
**
2
self
.
_c_socket
=
cprrt
.
PrrtSocket_create
(
target_delay_us
)
self
.
_c_socket
=
cprrt
.
PrrtSocket_create
(
target_delay_us
)
if
thread_pinning
:
if
thread_pinning
:
cprrt
.
PrrtSocket_enable_thread_pinning
(
self
.
_c_socket
)
cprrt
.
PrrtSocket_enable_thread_pinning
(
self
.
_c_socket
)
cprrt
.
PrrtSocket_bind
(
self
.
_c_socket
,
"0.0.0.0"
,
port
)
cprrt
.
PrrtSocket_bind
(
self
.
_c_socket
,
host
.
encode
(
"utf8"
),
port
)
property
plr_fwd
:
property
plr_fwd
:
def
__get__
(
self
):
def
__get__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment