You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Stuart Johnson <st...@stu.org.uk> on 2008/11/13 19:29:25 UTC

C# socket server

I want to create a server app capable of accepting multiple 
thrift-clients.  As each thrift client connects, it must send a login 
struct, which will be a username and password.

I have looked at the C# classes, and I am not sure where to start.  I 
can create the socket server, but I am unsure which class I need to 
attach to my socket.



Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
I would live to contribute to the wiki, but I seem to be lost in a sea 
of undocumented C# abstract classes at the moment. :)


Hannes Baldursson wrote:
> I've got nothing to add really, but would like to use the opportunity to
> encourage you all to add to the wiki once you've got things figured out to
> help others.
>
>
> On Thu, Nov 13, 2008 at 22:39, Stuart Johnson <st...@stu.org.uk> wrote:
>
>   
>> There is no TSerializer/TDeserializer, or at least nothing that looks like
>> that. Lots of abstract classes.
>>
>> There is a TStreamTransport. I'll have another look at that.
>>
>>
>>
>>
>> Bryan Duxbury wrote:
>>
>>     
>>> Then you're looking for whatever the equivalent of
>>> TSerializer/TDeserializer is in C#. You could also possibly use the
>>> equivalent of TIOStreamTransport, if there is one.
>>>
>>> On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:
>>>
>>>  I already have tried & tested C# code to create a socket server, that
>>>       
>>>> will run 1000's of incoming connections, and take care of authentication,
>>>> time-outs etc.
>>>> I want to rip out the proprietary protocol that is being used, and tie it
>>>> into thrift.  I cant quite get my head around the class library. Could do
>>>> with a block diagram to understand the hierarchy.
>>>>
>>>>
>>>> Ted Dunning wrote:
>>>>
>>>>         
>>>>> Ahhh....
>>>>>
>>>>> That makes much more sense as a question.
>>>>>
>>>>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk<mailto:
>>>>> stuart@stu.org.uk>> wrote:
>>>>>
>>>>>    The examples show how to set up a TCP connection, but not how to
>>>>>    attach the transport to an existing socket.
>>>>>
>>>>>
>>>>>
>>>>>           
>
>   


Re: C# socket server

Posted by Hannes Baldursson <ha...@gmail.com>.
I've got nothing to add really, but would like to use the opportunity to
encourage you all to add to the wiki once you've got things figured out to
help others.


On Thu, Nov 13, 2008 at 22:39, Stuart Johnson <st...@stu.org.uk> wrote:

> There is no TSerializer/TDeserializer, or at least nothing that looks like
> that. Lots of abstract classes.
>
> There is a TStreamTransport. I'll have another look at that.
>
>
>
>
> Bryan Duxbury wrote:
>
>> Then you're looking for whatever the equivalent of
>> TSerializer/TDeserializer is in C#. You could also possibly use the
>> equivalent of TIOStreamTransport, if there is one.
>>
>> On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:
>>
>>  I already have tried & tested C# code to create a socket server, that
>>> will run 1000's of incoming connections, and take care of authentication,
>>> time-outs etc.
>>> I want to rip out the proprietary protocol that is being used, and tie it
>>> into thrift.  I cant quite get my head around the class library. Could do
>>> with a block diagram to understand the hierarchy.
>>>
>>>
>>> Ted Dunning wrote:
>>>
>>>> Ahhh....
>>>>
>>>> That makes much more sense as a question.
>>>>
>>>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk<mailto:
>>>> stuart@stu.org.uk>> wrote:
>>>>
>>>>    The examples show how to set up a TCP connection, but not how to
>>>>    attach the transport to an existing socket.
>>>>
>>>>
>>>>
>>>
>>
>

Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
There is no TSerializer/TDeserializer, or at least nothing that looks 
like that. Lots of abstract classes.

There is a TStreamTransport. I'll have another look at that.



Bryan Duxbury wrote:
> Then you're looking for whatever the equivalent of 
> TSerializer/TDeserializer is in C#. You could also possibly use the 
> equivalent of TIOStreamTransport, if there is one.
>
> On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:
>
>> I already have tried & tested C# code to create a socket server, that 
>> will run 1000's of incoming connections, and take care of 
>> authentication, time-outs etc.
>> I want to rip out the proprietary protocol that is being used, and 
>> tie it into thrift.  I cant quite get my head around the class 
>> library. Could do with a block diagram to understand the hierarchy.
>>
>>
>> Ted Dunning wrote:
>>> Ahhh....
>>>
>>> That makes much more sense as a question.
>>>
>>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk 
>>> <ma...@stu.org.uk>> wrote:
>>>
>>>     The examples show how to set up a TCP connection, but not how to
>>>     attach the transport to an existing socket.
>>>
>>>
>>
>


Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
Yes, I have looked at the tests.  My server application may take up to 
1000's of simultaneous connections.  I am using the Socket class with 
ASycronious callbacks to implement an asynchronous server.  Thrift uses 
TCPListener, and TCPClient, and is creating a new thread for every 
connection.

So I would rather handle the sockets myself, and just pass the incoming 
data to Thrift for decoding.

Looking at it another way, if i wanted to store thrift data in a 
database table, how would I pass the data to and from thrift?



Craig Kimerer wrote:
> Have you tried the tests?
>
> If you look in trunk/test/csharp you should see more information.  I am not
> really sure what you are trying to accomplish but aren't able to.
>
> See http://svn.apache.org/viewvc?view=rev&revision=665633 It provides both a
> server and a client.
>
> Craig
>
>   


Re: C# socket server

Posted by Craig Kimerer <cr...@gmail.com>.
Have you tried the tests?

If you look in trunk/test/csharp you should see more information.  I am not
really sure what you are trying to accomplish but aren't able to.

See http://svn.apache.org/viewvc?view=rev&revision=665633 It provides both a
server and a client.

Craig

On Fri, Nov 14, 2008 at 7:00 PM, Stuart Johnson <st...@stu.org.uk> wrote:

> Does anyone know how to Serialize/Deserialize thrift data  in C#?  I have
> played around with TStreamTransport for a couple of days now, and I dont
> think it's going to be suitable.  I want each socket connection to run
> asynchronously, without having to spawn hundreds or thousands of threads.
>  Easy enough to do, except the C# thrift code is quite fragmented, and hard
> to know where to start.
>
>
>
>
> Bryan Duxbury wrote:
>
>> Then you're looking for whatever the equivalent of
>> TSerializer/TDeserializer is in C#. You could also possibly use the
>> equivalent of TIOStreamTransport, if there is one.
>>
>> On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:
>>
>>  I already have tried & tested C# code to create a socket server, that
>>> will run 1000's of incoming connections, and take care of authentication,
>>> time-outs etc.
>>> I want to rip out the proprietary protocol that is being used, and tie it
>>> into thrift.  I cant quite get my head around the class library. Could do
>>> with a block diagram to understand the hierarchy.
>>>
>>>
>>> Ted Dunning wrote:
>>>
>>>> Ahhh....
>>>>
>>>> That makes much more sense as a question.
>>>>
>>>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk<mailto:
>>>> stuart@stu.org.uk>> wrote:
>>>>
>>>>    The examples show how to set up a TCP connection, but not how to
>>>>    attach the transport to an existing socket.
>>>>
>>>>
>>>>
>>>
>>
>

Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
Does anyone know how to Serialize/Deserialize thrift data  in C#?  I 
have played around with TStreamTransport for a couple of days now, and I 
dont think it's going to be suitable.  I want each socket connection to 
run asynchronously, without having to spawn hundreds or thousands of 
threads.  Easy enough to do, except the C# thrift code is quite 
fragmented, and hard to know where to start.



Bryan Duxbury wrote:
> Then you're looking for whatever the equivalent of 
> TSerializer/TDeserializer is in C#. You could also possibly use the 
> equivalent of TIOStreamTransport, if there is one.
>
> On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:
>
>> I already have tried & tested C# code to create a socket server, that 
>> will run 1000's of incoming connections, and take care of 
>> authentication, time-outs etc.
>> I want to rip out the proprietary protocol that is being used, and 
>> tie it into thrift.  I cant quite get my head around the class 
>> library. Could do with a block diagram to understand the hierarchy.
>>
>>
>> Ted Dunning wrote:
>>> Ahhh....
>>>
>>> That makes much more sense as a question.
>>>
>>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk 
>>> <ma...@stu.org.uk>> wrote:
>>>
>>>     The examples show how to set up a TCP connection, but not how to
>>>     attach the transport to an existing socket.
>>>
>>>
>>
>


Re: C# socket server

Posted by Bryan Duxbury <br...@rapleaf.com>.
Then you're looking for whatever the equivalent of TSerializer/ 
TDeserializer is in C#. You could also possibly use the equivalent of  
TIOStreamTransport, if there is one.

On Nov 13, 2008, at 12:04 PM, Stuart Johnson wrote:

> I already have tried & tested C# code to create a socket server,  
> that will run 1000's of incoming connections, and take care of  
> authentication, time-outs etc.
> I want to rip out the proprietary protocol that is being used, and  
> tie it into thrift.  I cant quite get my head around the class  
> library. Could do with a block diagram to understand the hierarchy.
>
>
> Ted Dunning wrote:
>> Ahhh....
>>
>> That makes much more sense as a question.
>>
>> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson  
>> <stuart@stu.org.uk <ma...@stu.org.uk>> wrote:
>>
>>     The examples show how to set up a TCP connection, but not how to
>>     attach the transport to an existing socket.
>>
>>
>


Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
I already have tried & tested C# code to create a socket server, that 
will run 1000's of incoming connections, and take care of 
authentication, time-outs etc.
I want to rip out the proprietary protocol that is being used, and tie 
it into thrift.  I cant quite get my head around the class library. 
Could do with a block diagram to understand the hierarchy.


Ted Dunning wrote:
> Ahhh....
>
> That makes much more sense as a question.
>
> On Thu, Nov 13, 2008 at 10:40 AM, Stuart Johnson <stuart@stu.org.uk 
> <ma...@stu.org.uk>> wrote:
>
>     The examples show how to set up a TCP connection, but not how to
>     attach the transport to an existing socket.
>
>


Re: C# socket server

Posted by Stuart Johnson <st...@stu.org.uk>.
The examples show how to set up a TCP connection, but not how to attach 
the transport to an existing socket.

Ted Dunning wrote:
> The login part is easy.  You just create a method called login that returns
> a magic token.  Then all subsequent requests use the token (which should be
> signed and a little hard to reuse).
>
> Insofar as how to plug into the C# server, this is just like creating any
> other thrift server.  See the examples.
>
> On Thu, Nov 13, 2008 at 10:29 AM, Stuart Johnson <st...@stu.org.uk> wrote:
>
>   
>> I want to create a server app capable of accepting multiple thrift-clients.
>>  As each thrift client connects, it must send a login struct, which will be
>> a username and password.
>>
>> I have looked at the C# classes, and I am not sure where to start.  I can
>> create the socket server, but I am unsure which class I need to attach to my
>> socket.
>>
>>
>>
>>     
>
>
>   


Re: C# socket server

Posted by Ted Dunning <te...@gmail.com>.
The login part is easy.  You just create a method called login that returns
a magic token.  Then all subsequent requests use the token (which should be
signed and a little hard to reuse).

Insofar as how to plug into the C# server, this is just like creating any
other thrift server.  See the examples.

On Thu, Nov 13, 2008 at 10:29 AM, Stuart Johnson <st...@stu.org.uk> wrote:

> I want to create a server app capable of accepting multiple thrift-clients.
>  As each thrift client connects, it must send a login struct, which will be
> a username and password.
>
> I have looked at the C# classes, and I am not sure where to start.  I can
> create the socket server, but I am unsure which class I need to attach to my
> socket.
>
>
>


-- 
Ted Dunning, CTO
DeepDyve
4600 Bohannon Drive, Suite 220
Menlo Park, CA 94025
www.deepdyve.com
650-324-0110, ext. 738
858-414-0013 (m)