3

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))

1 Answer 1

1

Try the following

(import [System.Net.Sockets Socket AddressFamily SocketType ProtocolType])
(Socket. AddressFamily/InterNetwork SocketType/Dgram ProtocolType/Udp)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.