Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Dear monks,

EDIT: I read that in Perl working with sockets is just like working with file handles - and in some weird way assumed that both sides can't write to it at the exactly same time. That of course makes sense IMO for (one) file - but not quite for the sockets - so can both sides write at the same time?

If they can indeed both write at the same time - and read what they are receiving (if there is anything - will use can_read() to check) when they want (when they are not sending) - then I'm all settled and clear. Each operation is accompanied by some unique (circulating 00 to 99) number - and it's response to the other side also includes that number.



I need some guidance regarding network programming - and specifically it would be excellent if someone has EMI/UCP protocol experience.

My first hope was to use Net::UCP or Net::EMI - just like I did with excellent Net::SMPP - but I just can't get either of these two to work. Finding out that in reality only a small subset of operations (commands) defined in EMI/UCP protocol is still in use today (for SMS's anyway) (and I need even smaller - getting to ~ 5 commands) I would like to give a shot at writing my own implementation.

I understand almost everything but one thing - how is synchronization done? I see there are commands that server initiates (sms delivery report as one of them) - and I wonder how can I know when I can write to a socket?

EMI/UCP specification leaves much to be desired (docs of Net::EMI and Net::UCP even more so) in terms of explaining the "whole forest" and not just specific "trees". So if anyone knows specifically for it - but even in general network programming - how does one sync up the server and client and ensure that they are not both trying to send at the same time, and there are no lockups (race conditions).

Is IO::Select and it's methods can_read() and can_write() enough of a check? I keep wondering - especially since the other side might try to write in the time our first write packet reaches the remote side so it's can_write() still returns yes you can write ...

OTOH as I understand in most (all?) protocols it's actually only one side that can initiate the write (if only one socket is used for communication) - either send something or ask "do you have anything new for me?" and then wait for the other side to respond - am I on the right track?

I also see that operations in UCP that are not response (ACK, NACK) contain a field called MMS (more messages to send) that I guess means - here you have this, but I keep the write permissions after you send me back ACK/NACK?

PS. All I need is a way to connect to server (UCP SMSC), login, send a message (a lot of them actually), receive the delivery notification (for all the messages) and perhaps do a ping (alert operation 31) as a "keep alive". But in lack of existing UCP SMSC software - I need to first write a dummy one - to be used for testing.

Have you tried freelancing/outsourcing? Check out Scriptlance - I work there since 2003. For more info about Scriptlance and freelancing in general check out my home node.

In reply to Server/client sync - when can I write to a socket? by techcode

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-23 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found