IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1822.41 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-09-04
[21:43]<rrrdjdtxyrr>Aha
[21:43]<rrrdjdtxyrr>I've worked it out :)
[21:43]<zzgmzjym>RandomThing: Great!
[21:43]<pzggjgg1000>...Is there anything that would be really cool if it was done/
[21:43]<rrrdjdtxyrr>And it wasn't even my problem to start with...
[21:43]<rrrdjdtxyrr>but I feel I've learned lots :)
[21:44]<rrsync>whats wrong with that code ;/
[21:45]<zzgmzjym>jasiek: The code you just posted won't work because you cannot get a raw pointer to a byte array unless you use the "fixed" keyword.
[21:46]<rrrdjdtxyrr> gg_header data = new gg_header();
[21:46]<rrrdjdtxyrr> sock.Receive(recv, 8, System.Net.Sockets.SocketFlags.None);
[21:46]<rrrdjdtxyrr> unsafe { fixed (byte* p = recv) Marshal.PtrToStructure(new IntPtr(p), data); }
[21:46]<rrrdjdtxyrr>something like that?
[21:46]<rrrdjdtxyrr>(or maybe not... it compiles at least)
[21:46]<rrsync>let me check
[21:46]<zzgmzjym>RandomThing: hm.
[21:47]<zzgmzjym>RandomThing: I though the second argument of PtrToStructure was a Type.
[21:47]<zzgmzjym>*thought
[21:48]<rrrdjdtxyrr>erm...
[21:48]<rrrdjdtxyrr>I'll go check what I'm doing... 2 secs
[21:48]<zzgmzjym>unsafe { fixed(byte *p = recv) { data = (gg_header)Marshal.PtrToStructure(new IntPtr(p), typeof(gg_header); } }
[21:48]<zzgmzjym>Which is more or less what I posted above.
[21:48]<rrrdjdtxyrr>can be either
[21:48]<zzgmzjym>RandomThing: Oh that's cool.
[21:48]<rrrdjdtxyrr>one returns object, the other is void
[21:48]<zzgmzjym>So it just figures out the type itself.
[21:48]<rrrdjdtxyrr>other returns void, even
[21:49]<zzgmzjym>So, yours is probably easier.
[21:49]<zzgmzjym>Less casting.
[21:49]<rrrdjdtxyrr>yours shouldwork too I think
[21:49]<rrrdjdtxyrr>if the compiler's decent it should optimise it tho, right?
[21:49]<rrrdjdtxyrr>so they should end up the same?
[21:49]<esjd>how to use a cmd tool (other application) in a c# development? i want to use e.g. dsadd for making users in Active Directory, and the application i make shall use the dsadd command?
[21:50]<esjd>is this possible? really hope so.. =)
[21:50]<zzgmzjym>It's hottie-o-rama here at Starbucks. This blond is so hot I'm going to have to change my shorts, but since she's with her mom it's probably illegal for me to even look at her. :p
[21:50]<rrrdjdtxyrr>EsoD: Is it not possible to program to AD directly?
[21:50]<zzgmzjym>RandomThing: I would think so. I doubt that's even an issue.
[21:51]<esjd>RandomThing: i dont really know, tried searching the web (some) i'm a bit new to C#, but find it really interessting
[21:51]<rrsync>it compiles now...
[21:51]<zzgmzjym>EsoD: I probably would just use the System.DirectoryServices stuff instead (or whatever it's called).
[21:52]<zzgmzjym>EsoD: .NET already has objects to work with AD.
[21:52]<esjd>nice
[21:52]<zzgmzjym>EsoD: Calling out to a command-line tool will be a serious pain in the ass. You want to avoid it at all costs.
[21:52]<zzgmzjym>EsoD: Difficult to check errors, etc.
[21:52]<esjd>See. Thanks
[21:53]<rrsync>Marshal.PtrToStructure(new IntPtr(p), typeof(gg_header));
[21:54]<zzgmzjym>jasiek: Cool.
[21:54]<rrsync>what typeof(gg_header) means..?
[21:54]<rrsync>and why isn't it gg_header CONN
[21:54]<rrsync>struct..
[21:54]<zzgmzjym>It tells Marshal.PtrToStructure what kind of an object gg_header is, so it knows how to do its magic behind the scenes. typeof() returns a Type object that describes gg_header to C#.
[21:55]<zzgmzjym>Type gg_headerType = typeof(gg_header);
[21:55]<rrsync>I dont understand..
[21:56]<rrsync>Marshal.PtrToStructure(new IntPtr(p), CONN); also compile..
[21:56]<zzgmzjym>jasiek: The Type object provides runtime type information about objects. It has no equivalent at all in C, where types don't really exist at runtime. In C++, there is runtime type information.
[21:56]<zzgmzjym>jasiek: That will work, too, as RandomThing showed.
[21:57]<zzgmzjym>jasiek: I meant, in C++, there is limited runtime type information, depending upon the implementation.
[21:58]<rrsync>ehh too much information :)
[21:58]<zzgmzjym>jasiek: What you're doing is really pretty advanced, you know. :)
[21:59]<rrrdjdtxyrr>Hey... I worked out something that was advanced :)
[21:59]<rrrdjdtxyrr>Now I feel good :)
[21:59]<zzgmzjym>hehe
[21:59]<zzgmzjym>I'm amazed I did as well as I did without VS in front of me.
[22:00]<zzgmzjym>hehe
[22:02]<rrsync>strange...there is next error :/
[22:02]<rrrdjdtxyrr>which is?
[22:02]<rrsync>while I am trying to execute program
[22:02]<zzgmzjym>jasiek: There's always a next error. That's the story of my life, really.
[22:02]<rrsync>System.ArgumentException: The structure must not be a value class.
[22:02]<rrsync>Parameter name: structure
[22:02]<zzgmzjym>:)
[22:02]<rrsync>System.ArgumentException: The structure must not be a value class.
[22:02]<rrsync>Parameter name: structure
[22:03]<zzgmzjym>jasiek: I don't understand that at all. I would think it would *have* to be a value class.
[22:03]<rrrdjdtxyrr>want to pastbin the code?
[22:03]<rrrdjdtxyrr>pastebin*
[22:03]<rrsync>yeah
[22:04]<rrsync>http://nomorepasting.com/paste.php?pasteID=68147
[22:05]<rrsync>LOG is richtextbox with logs
[22:06]<rrsync>and what do you think about it?
[22:08]<rrrdjdtxyrr>Doesn't Socket.Connected only work after a send/recv?
[22:08]<rrrdjdtxyrr>or does opening it count as a send/recv?
[22:08]<rrsync>i dont know
[22:09]<rrrdjdtxyrr>bah... ignore that...
[22:10]<rrrdjdtxyrr>it should be valid after a connect (i think)
[22:10]<rrrdjdtxyrr>The Connected property gets the connection state of the Socket as of the last I/O operation. When it returns false, the Socket was either never connected, or is no longer connected.
[22:10]<rrsync>i deleted connected check but its still wrong
[22:10]<rrrdjdtxyrr>I didn't think that was going to help, I was just kinda thinking out loud.
[22:11]<zzgmzjym>RandomThing: I hardly ever, ever use sockets. I tend to use higher-level constructs like Remoting or web services.
[22:12]<rrrdjdtxyrr>Hmm... Would that work with trying to, say, communicate with IMAP servers?
[22:12]<zzgmzjym>jasiek: OK, hold on. I will start up Visual Studio and play around with this.
[22:13]<zzgmzjym>Well, I'm using Visual C#, but it's much the same.
[22:14]<rrsync>Randroid: thanks..
[22:14]<rrsync>send you a project file?
[22:14]<zzgmzjym>jasiek: No, it's OK.
[22:16]<rrsync>ok, so ill wait
[22:16]<zzgmzjym>jasiek: Yeah. :)
[22:16]<zzgmzjym>jasiek: Well, one thing you'll have to do is decorate your structure definition with [StructLayout(LayoutKind.Sequential)]
[22:17]<rrrdjdtxyrr>put CONN = (gg_header)Marshal.PtrToStructure(new IntPtr(p), typeof(gg_header)); in and it seems to work
[22:17]<zzgmzjym>RandomThing: You tried it?
[22:17]<rrrdjdtxyrr>that may have been my fault.







