|
Hi,
When i try to connect diffrent ip addres the following exception are comming.
"Cannot block a call on this socket while an earlier asynchronous call is in progress.at System.Net.Sockets.Socket.ValidateBlockingMode()"
If i use same system, so the ip is same, its working properly. also in some diffrent systems connection is ok.
When i debug i get the LocalEndPoint = 0.0.0.0 : "port numbet".
Following are the code for connecting with listening server
m_sock = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
IPEndPoint epServer = new IPEndPoint( IPAddress.Parse( "listening server IP address" ), 399 );
m_sock.Blocking = true;
onconnect = new AsyncCallback( OnConnect );
m_sock.BeginConnect( epServer, onconnect, m_sock );
How can i rectify this?
Regards,
Yesuprakash
modified on Wednesday, December 17, 2008 3:00 AM
|
|
|
|
|
i've a form and when it loads it creates a new thread, with in that thread it creates another new thread , while in being in this thread i want to add a list view to the form, any suggestions ?
i tried
this.Container.Add(new ListView(),"lstvw");
lstvw.Items.Add(lst);
but the listview is not displayed on the form ;
|
|
|
|
|
You need to use Invoke/BeginInvoke. Let the main thread which hosts the UI create the control.
|
|
|
|
|
|
Ok, suppose I have the following line:
xxxxxxxx Here: #1111# xxxxxxxxxxx Here: #2222# xxxxxxxxxxx Here: #3333# xxxxxxxxxxx
How do I extract the value 2222 or 3333 alone
Please help
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
With a regex, or with the string.split, or even substring methods. It really depends on what possible values you expect to find, that is, if the 2222 is always 4 digits, always at the same position, always surrounded by #, if there's any other #, etc.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks Christian, me too, but I'm looking for another way to do it like Regex
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Use:
using System.Text.RegularExpressions.RegEx;
RegEx finder = new RegEx("( Here: #(?<Number>\\d+)#) ", RegExOptions.ExplicitCapture);
foreach(Match match in finder.Matches("xxxxx Here: #1111# Xxxxxxxx Here: #2222# xxxxx"))
{
string number = match.Groups["Number"].Value;
}
To code, or not: Too code!
|
|
|
|
|
Hey,
Thanks, actually, I wanted to mention RegEx in my question but I wasn't sure I needed it in my case, can you tell me though how to reference the library in full cuz I can only get System.Text.RegularExpressions but not the .RegEx it doesnt branch anymore from that, besides, can you kindly link me to a good tutorial/reference to using RegEx.
Thanks mate!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
If you use the RegularExpressions namespace, RegEx is a class with static methods which he is calling.
The O'Reilly book 'mastering regular expressions' is the best resource available on the topic.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: O'Reilly book...
Hmmm, I should get one today, thanks Christian!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Still cant get it , I tried to play around with it but I screwed it..
Listen, I'm sorry but can you get me ip address alone out of the following??
Received: from [82.114.186.143] xxxxxxxxxxxxxxxx
Thanks again mate!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Well, I don't know much at all about Regex, but it seems to me that you'd try to find out if there's a way to say "give me everything between the brackets". There must be a wildcard character that does this. The example provided earlier that shows how to get everything between the '#' characters would give you a stepping off point.
Be a programmer, and work it out.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
i have added an Enum as a property in a class then attach that class to PropertyGrid. It shows a combobox in PG but problem is that whenever i select any item from that combobox, its text keep blank. I used a TypeConverter for that class. Anybody know how to solve this ?
here is code
class ProperyConverter : TypeConverter
{
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context,
object value, Attribute[] filter)
{
return TypeDescriptor.GetProperties(value, filter);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
}
[TypeConverter(typeof(ProperyConverter))]
class ABC
{
object[] data;
public ABC(object[] data)
{
this.data = data;
}
public override string ToString()
{
return data[0].ToString();
}
public MYEnum AAA
{
get { return (MYEnum)Convert.ToInt32(this.ToString()[0]); }
set { setValue(0, ((int)value).ToString()); }
}
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Please post the code, it should work the way you described
Regards,
Lev
|
|
|
|
|
first post updated
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
The problem seems to be in your property getter/setter.
I've changed the code and it works great (don't know you setdata func, so I just assigned the stuff):
get { return (MYEnum)Convert.ToInt32(data[0]); }
set { data[0] = value; }
BTW, getting the value of data, via ToString() is not that good, you've got the private data anyway
BTW2, you do not have any checks on the array, what if I init the ABC class with empty array?
Regards,
Lev
|
|
|
|
|
Lev Danielyan wrote: BTW2, you do not have any checks on the array, what if I init the ABC class with empty array?
setValue() have everything
Lev Danielyan wrote: get { return (MYEnum)Convert.ToInt32(data[0]); }
nope, you cannot Convert direct from object to int32 AFAIK because its type string...
Lev Danielyan wrote: I've changed the code and it works great
what you mean by works great ? doest it shows the selected enum or still blank ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen wrote: nope, you cannot Convert direct from object to int32 AFAIK because its type string...
It is not string in your code, it is object. Convert.Toint32 has an overloaded version to get object, even if it didn't it will work if you have strings or any other types that toint32 "understands".
Xmen wrote: what you mean by works great ? doest it shows the selected enum or still blank ?
When I ran you code the current selection was blank, but it wouldn't let me choose any other option (when i was clicking on any combo item it wasn't "fixing" it as current selection), in the code I posted the initial selection was also blank but it was keeping the selection from combo items. Isn't it what you wanted?
Regards,
Lev
|
|
|
|
|
Lev Danielyan wrote: but it was keeping the selection from combo items.
i dunno what are excatly you saying but my problem is just that its not showing selected item, eg when you select an item from combobox, it get appear infront of dropdown arrow. But this time in PG its not happening, when i select item, it does some calculations but doest appear selected(infront of dropdownbutton)
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hmm , it appears on my side (screen[^])
Maybe there are problems in the code you haven't posted?
Regards,
Lev
|
|
|
|
|
did you change the Type Converter ?
here is the screen of mine, blank even after selecting
http://img95.imageshack.us/my.php?image=62694072re0.png[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
i found the problem + solution
Convert.ToInt32(this.ToString()[0])
this.ToString()[0] string is returning a char and then when Convert class convert that char to ascii value to the value it has and that Enum do not has that value thats why its blank.
while if i use this.ToString().Substring(0,1) it works
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I still don't get why are you getting the internal data via ToString.
This is not the right thing to do.
Quoting MSDN "This method returns a human-readable string that is culture-sensitive", not more, you better redesign your class to get rid of this
Regards,
Lev
|
|
|
|
|
Lev Danielyan wrote: I still don't get why are you getting the internal data via ToString.
hehe because you didnt read code carefully, the code needs to rip one char from string then convert it to int then Enum. eg here is my string "1234"
i dont need 1234 as number, i'll need 1, 2, 3 and 4, so without converting it to string it wont happen. And i use this.ToString() because its same as data[..............].ToString(), i didnt use it because the line will be larger because i use some calculation to get the index.eg.
Override ToString()
{
return data[long .............. calculation].ToString();
}
Now which is better in appearing
Convert.ToIn32(data[long .............. calculation].ToString().Substring(0,1)); // long calculation again, breaking OOPS rule
or
Convert.ToIn32(this.ToString().Substring(0,1));
both does same, just last one calls one more method that is this.ToString() and i dont think its a bad idea
hope you got me
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|