Oliver Gu avatar Oliver Gu committed 1270a37

Port number for TWS clients is no longer optional

Comments (0)

Files changed (4)

+2013-04-18: Port number for TWS clients is longer optional.
+
 2013-04-16: Added a new interface Twsable.
             A type is 'Twsable' if it provides functions to convert between
             values of that type and raw messages of the TWS protocol.

lib/client_intf.ml

 
   type t
 
-  (** [with_client ~host ~on_handler_error handler] connects by default
-      to the IB Gateway (running on [host] under port 4001) and runs the
-      [handler] until an exception is thrown or until the returned Deferred
-      is determined.
+  (** [with_client ~host ~port ~on_handler_error handler] connects to the
+      IB connectivity software on ([host], [port]) and runs the [handler]
+      until an exception is thrown or the returned Deferred is determined.
 
       [on_handler_error] determines what happens if the [handler] throws an
       exception.
 
-      In order to connect to TWS, you need to supply 7496 as port number.
+      The standard port for TWS is 7496 and for the IB Gateway it is 4001.
   *)
   val with_client
     :  ?enable_logging:bool
     -> ?client_id:Client_id.t
-    -> ?port:int
     -> host:string
+    -> port:int
     -> on_handler_error:[
     | `Raise
     | `Ignore
 
   val is_connected : t -> bool
 
-  (* [state t] returns the state of the connection. *)
+  (** [state t] returns the state of the connection. *)
   val state : t -> [ `Disconnected | `Connecting | `Connected ]
 
   (** [set_server_log_level level] sets the log entry detail [level] of TWS
   let create
       ?(enable_logging = false)
       ?(client_id      = Client_id.of_int_exn 0)
-      ?(port = 4001)
-      ~host () =
+      ~host
+      ~port
+      () =
     return
       { client_id;
         enable_logging;
   let with_client
       ?enable_logging
       ?client_id
-      ?port
       ~host
+      ~port
       ~on_handler_error
       handler =
     let module C = Client_msg in
     Monitor.try_with (fun () ->
-      create ?enable_logging ?client_id ?port ~host ()
+      create ?enable_logging ?client_id ~port ~host ()
       >>= fun t ->
       if t.enable_logging then begin
         Stream.iter (messages t) ~f:(fun clt_msg ->
   val create
     :  ?enable_logging:bool
     -> ?client_id:Client_id.t
-    -> ?port:int
     -> host:string
+    -> port:int
     -> unit
     -> t Deferred.t
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.