Reputation: 1837
I'm trying to figure out proper syntax for interop with .Net System.Net.Sockets. My problem is the enumeration parts of the arguments. Here is the equivalent code in c#:
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
In clojure-clr I'm trying the following:
(System.Net.Sockets.Socket. (AddressFamily/InterNetwork) (SocketType/Dgram) (ProtocolType/Udp))
I'm getting CompilerException.InvalidOperationException. I reviewed https://github.com/clojure/clojure-clr/wiki/Working-with-enums regarding the enum but not understanding it.
I've also tried:
(System.Net.Sockets.Socket. (.InterNetwork AddressFamily) (.Dgram SocketType) (.Udp ProtocolType))
Upvotes: 3
Views: 161
Reputation: 2539
Try the following
(import [System.Net.Sockets Socket AddressFamily SocketType ProtocolType])
(Socket. AddressFamily/InterNetwork SocketType/Dgram ProtocolType/Udp)
Upvotes: 1